0
votes

tests running in eclipse, mvn test, command line also but not in jenkins. maven surefire plugin in console says no test to run. I suspect maven surefire plugin not able to pick tests. my POM looks like :

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 groupid artifactiddemo 0.0.1-SNAPSHOT

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.2.6</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>4.2.6</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
    </dependency>




</dependencies>
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>
    <packaging>jar</packaging>
</properties>
<build>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.8.1</version>

        </plugin>
    </plugins>
</build>

AND JENKINS JOB LOGS ARE : 



Executing Maven:  -B -f C:\Program Files (x86)\Jenkins\workspace\Second_Job\pom.xml verify -Dcucumber.options=test/features/FirstDemo.feature -DskipTests=false
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< groupid:artifactiddemo >-----------------------
[INFO] Building artifactiddemo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ artifactiddemo ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\Second_Job\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ artifactiddemo ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ artifactiddemo ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\Second_Job\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ artifactiddemo ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.8.1:test (default-test) @ artifactiddemo ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Program Files (x86)\Jenkins\workspace\Second_Job\target\surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

I know I am missing on something to include testsin surefire plugin thing .. but they are running smoth on local eclipse or mvn test command. Thanks in advance

1
Check and ensure that you have test classes inside test folder, are you able to run locally ? - Sambit

1 Answers

1
votes

You did not provide any information about your test classes. Make sure that the class names of your tests match one of these patterns:

  • "**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test".
  • "**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test".
  • "**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests".
  • "**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".