- download windows installer @http://jenkins-ci.org/
- dashboard available @http://localhost:8080/
2. java and maven installed
- download maven @https://maven.apache.org/
- setup 'PATH' and 'MAVEN_HOME' env variable for maven
3. make sure tests run on local folder first before moving them to jenkins folder
4. standard folder structure using maven (test scripts must be under src/test/java, name must be *Test.java)
project
pom.xml
src
test
java
yourTest.java
cd /users/anoop/project
mvn test
5. by default, maven uses the following naming conventions when looking for tests to run
- **/Test*.java - includes all subdirectories
- **/*Test.java - includes all subdirectories
- **/*TestCase.java - includes all subdirectories
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
</plugin>
6. configure testNG test (maven-surefire-plugin)
<plugin>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${xmlPath}/testSuite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<suite name="suite1">
<test name="regression1">
<classes>
<class name="packagename.classname" />
</classes>
</test>
</suite>
mvn test -DxmlPath=c:/some/path
//be careful that package name in testSuite.xml is the package name in java file, not necessarily the "test/java/..." path name
7. rerun failed testNG test (maven-surefire-plugin)
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng/testng.xml</suiteXmlFile>
<suiteXmlFile>target/surefire-reports/testngfailed.xml</suiteXmlFile>
</suiteXmlFiles>
8. include junit test with different name pattern or exclude junit test (maven-surefire-plugin)
<configuration>
<includes>
<include>sample.java</include>
</includes>
</configuration>
<excludes>
<exclude>**/TestCircle.java</exclude>
<exclude>**/TestSquare.java</exclude>
</excludes>
9. to run testNG or junit test in parrallel
<plugin>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
reference:
1. selenium jenkins - how to do it yourself and the sauce labs advantage
2. my software builds on my computer but not on jenkins
3. maven surefire plugin
4. maven goals and options
5. testing a web application with selenium 2
6. maven does not find junit tests to run
No comments:
Post a Comment