Should we need TestNG or Junit framework to integrate Selenium with Jenkins. I have project which is build without TestNG or JUnit can i integrate it with Jenkins.
Does Selenium- Jenkins Integration needs TestNG or JUnit Framework
434 views Asked by ms surya kumar At
2
There are 2 answers
0
On
You can use both JUnit
and TestNG
frameworks as Jenkins supports both.
Steps in details for TestNG
integration with Jenkins
.
Step 1: Create Free Style project in Jenkins and fill the details and Save the project.
Step 2: click on Configure
Step 3: In the Build section of Configure:
java -cp J:\taf\testng\*;J:\taf\workspace\TestNGExamples\bin;J:\automation\* org.testng.TestNG J:\taf\workspace\TestNGExamples\testng1.xml
Note: you have to change the paths as per your system.
In -cp
argument, we must provide testng.jar
, project location
and ``selenium jarslocations/paths.
org.testng.TestNG- TestNG Main Class.
and
location to the XML of testng configuration`
Download and install the testng-plugin
for jenkins from here and restart Jenkins in order to take effect.
Step 4: In the Post-build Actions
section,
- Select Publish TestNG Results from Add post-build action dropdown.
- provide the path where to look for TestNG results (.xml file containing results).
- Click Apply and Save buttons.
Screenshot for reference:
TestNG and JUnit on simple terms can be visualised as "java code execution" mechanisms with support to do validations. So instead of you having only one
main()
method that would be the single point of entry for execution of your selenium code, TestNG/JUnit takes up that role and lets you run multiple java classes via themselves.Jenkins is an orchestrator tool that lets you build, test, deploy as per your wish.
The test phase can be skipped by not using TestNG and JUnit, and you resorting to executing your selenium based tests via a
main()
method which takes care of doing all validations as well (assertions in the JUnit/TestNG world)