TestNG options not display in Run As in eclips even I added Test NG Jar - selenium

I have added testng-7.4.0.jar in my project as external jar but I am not getting TestNG as options to run the program under run as in eclipse . I can see TestNg jar present in Referenced Libraries
I tried this in both version of eclipse oxygen and Neon
enter image description here

Install Testng plugin from eclipse market place and restart the IDE. And when you run it for the first time configure the run with run configurations.

You must have TestNG.xml file configured to run in eclipse.

Related

How to setup TestNG in selenium webdriver?

I am using selenium webdriver for website testing. Now I want to setup TestNG in my selenium webdriver. How it possible? Is there any JAR files for testng?
Add testng maven dependency to your pom.xml file. Jars will be auto downloaded. Then you can start using testng in your project.
https://mvnrepository.com/artifact/org.testng/testng
YOu can see all versions her, download the JAR files or use the dependencies in your POM.xml if you use Maven
You can get the testng from the eclipse market place by searching Testng,simple install that you can now use testng on your project.
You can also find this jar for testng libraries and add it to your project.
http://testng.org/testng-6.8.zip
You can install testng from Market place if not found install as software. Details are provided in documentation
https://testng.org/doc/download.html
Once installation is done and eclipse restarted then add TestNG library to you project and then good to go.
For build tools you need testng jars, you can download from maven repository. If you are using maven add dependency in pom.xml as said in another answer.
First you need to install TestNG from - TestNG P2 - https://testng.org/testng-p2-update-site. Steps are mentioned below:-
Launch Eclipse and go to Help option present at the top and select -"Install New Software".
A new dialog box will appear. Mention Name as TestNG and location as "http://beust.com/eclipse/" and click on Add button.
This time we will see TestNG added in Install dialog box.
Once the installation is completed, you will get a message to Restart the Eclipse and select to Restart the Eclipse.
You are all set. In case you want to know more about TestNG, you can refer this link.

Should selenium tests be kept in separate project

I have a Java web app (Maven) where I have some Selenium tests.The testing framework is Junit 4.x.
I'm also using Jenkins for CI. Right now all my tests (integration + selenium) are kept under the src/test folder of the project.(classic maven structure)
Due to the fact that Jenkins cannot run selenium tests (it is not configured to do this - I'm running on a linux machine without a graphical interface and the solutions under this circumstances seems a little clumsily, but I was thinking to run a selenium server so that I can run all these tests on a windows slave machine ) I have to manually "remove from execution the selenium tests", otherwise I'll have a lot of failed tests.
What I want to accomplish is a scenario where:
1.Commit to SVN
2.Jenkins creates a build
3.Run the tests and if there is no problem here move to next step, otherwise,stop
4.Deploy the app to an app server
5.Run the selenium tests against that deployment as a post build script in Jenkins.
In order to have this running do I have to extract the selenium tests to other project ? (in order to avoid Jenkins running this tests along with the other integration/unit tests)
As you are using Maven and you say kept under the src/test folder of the project sounds just Perfecto.
You havn't mentioned in your question why Jenkins cannot run selenium tests (it is not configured to do this). As later in your question you have mentioned Run the tests, presumming you are using TestNG it's just one step configuration for Jenkins to execute pom.xml of Maven which will inturn call the *testng.xml as mentioned below :
Ensure your Automated Test Suite executes properly as TestNG Suite and Maven Test.
Start Jenkins and browse to Manage Jenkins -> Configure System
Scroll Down to JDK -> JDK installations and ensure JAVA_HOME is set to C:\path\to\jdk1.8.0_144. Uncheck Install automatically
Scroll Down further to Maven -> Maven installations and provide Name as MAVEN_HOME & MAVEN_HOME as C:\path\to\apache-maven-3.3.3. Uncheck Install automatically
Scroll Down to JDK -> JDK installations and ensure Local Maven Repository is set to Default(~/.m2/repository).
Apply & Save
On Jenkins Dashboard, Create a New Item as Maven project.
Scroll Down to Build section and provide Root POM as absolute path of the pom.xml e.g. C:\Users\<user_name>\LearnAutmation\maven.jenkins\pom.xml
Set Goals and options to clean install
The final step would be to move the testng.xml within \ProjectWorkSpace\src\main\resources\testng.xml and your pom.xml you have to mention the location of testng.xml as below :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
Build your project through Jenkins
As per your specific question In order to have this running do I have to extract the selenium tests to other project ? the answer is No.
Solution :
If you want to execute both the Suites Integration and Selenium, this setup is yours.
If you want to execute either of the Suites seperately, divide the Integration and Selenium suites in different TestNG Groups and turn ON & OFF the execution of the TestNG Groups.

How to build RPM of a selenium test automation project with maven?

I have a test automation framework with test cases. I want to build an RPM of this whole project so that it can be installed on any machine and can execute the test. How can I do that?
One approach is to use a %check scriptlet in a spec file to run the tests during a build.

TestNG tests don't start in IntelliJ 13.1.4

I am unable to run or debug any TestNG tests in IntelliJ 13.1.4 on my Mac. When I try to run the test in debug mode, the IDE is hung starting the test - it never completes.
However, I can work with the same test using an older version of IntelliJ (12.1.7).
So far I've tried changing the JDK, replacing the testng jar in ../IntelliJ13/plugins/testng/lib, reimporting all maven dependencies, rebuilding IntelliJ indices.
Any ideas about how to fix my IntelliJ 13.1.4 environment?
I had similar issue - it turns out that I need to config my JVM options and connection used.
Update:
Sadly no, they are internal resources. But the algorithm should be the same (for your case):
goto Run/Debug Configuration
select TestNG
add your Name for the new configuration
select path to your test suite in Suite
in JDK settings tab, find VM options input your connection configs
run/debug for the Run/Debug Configuration - menu arrows
this worked for me.

Do we need to install JDK to run WebDriver's TestNG tests through command line?

I am new to Selenium/WebDriver and created a project which I can execute through Eclipse IDE successfully. Now, I plan to run the test through command prompt by creating the proper TestNG1.xml and making sure the testng-6.8.5.jar is correctly pointed in PATH. I even tried giving full path of the testng-6.8.5.jar. Unfortunately I keep getting the error,
Error: Could not find or load main class org.testng.TestNG
I don't have JDK installed (and I don't want to install) so wondering if JDK is mandatory to run TestNG tests from Command line? From above error it looks like it's not even trying to access the TestNG1.xml I have.
I plan to distribute these tests as group of files to my fellow Business Analyst who only have JRE installed on their machine.
Yes, you need JDK installed where you are going to run your Test Here is some documentation of TestNG
Having JRE is enough to run the TestNG tests, or no need to install JDK to run the TestNG tests through command line
the issue was with the testng-6.8.5.jar library as selenium-server-standalone-2.32.0.jar was allowing me to run the project with no errors.