java - JUnit test with Maven in a Jenkins plugin -
i have problem when tried run junit tests maven. jenkins plug-in wrote class test. example: have class consoleparser
in package com.jenkins_plugin in folder src/main/java. junit test case consoleparsertest
in package com.jenkins_plugin in folder src/test. running junit test added dependency in pom:
<dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.11</version> </dependency> </dependencies>
and ran in cmd next command: mvn -dtest=consoleparsertest test
the problem i've got following error:
[error] failed execute goal org.apache.maven.plugins:maven-surefire-plugin:2. 12:test (default-test) on project swatt_jenkins: no tests executed! (set - dfailifnotests=false ignore error.) -> [help 1]
the full pom.xml is:
<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <build> <finalname>jenkins_plugin</finalname> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.12</version> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>emma-maven-plugin</artifactid> <version>1.0-alpha-3</version> <inherited>true</inherited> <executions> <execution> <phase>process-classes</phase> <goals> <goal>instrument</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <parent> <groupid>org.jenkins-ci.plugins</groupid> <artifactid>plugin</artifactid> <version>1.526</version> </parent> <groupid>jenkins_plugin</groupid> <version>1.0</version> <packaging>hpi</packaging> <repositories> <repository> <id>repo.jenkins-ci.org</id> <url>http://repo.jenkins-ci.org/public/</url> </repository> </repositories> <pluginrepositories> <pluginrepository> <id>repo.jenkins-ci.org</id> <url>http://repo.jenkins-ci.org/public/</url> </pluginrepository> </pluginrepositories> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.11</version> </dependency> </dependencies> </project>
also, must mention settings ran test after adding findbugs crashed. so, removed findbugs , try run test again problem mentioned appeared. so, can explain have do? tried add version of junit, surefire had same problem , don't understand why.
several things:
- add junit classes
src/test/java
notsrc/test
- for junit class use scope "test"
e.g.:
<dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.11</version> <scope>test</scope> </dependency>
also recommend manage repositories in repository manager such nexus, not in pom:
http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html
Comments
Post a Comment