Java, Maven + Jenkinsfile - Cannot find classpath - java

I've got a weird one. I'm running a series of Java tests via Maven locally using the command line successfully:
LeveneS#WS3748 MINGW64 /h/Coding/workspace/[MY-PROJECT] (initalCommit)
$ mvn surefire-report:report test site
[INFO] Scanning for projects...
[INFO]
[INFO] ---< [MY-PROJECT] >----
[INFO] Building [MY-PROJECT] 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ...etc...
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.ExampleTest
40 Scenarios (40 passed)
91 Steps (91 passed)
0m0.322s
[INFO] Tests run: 131, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.01 s - in com.example.ExampleTest
I want to run this in Jenkins using multi-branch pipeline; so I've created a Jenkinsfile as such:
pipeline {
agent { docker { image 'maven:3.6.1' } }
stages {
stage('Installation') {
steps {
sh 'mvn --version'
sh 'mvn install'
}
}
stage('Run') {
steps {
sh 'mvn surefire-report:report test site'
}
}
}
}
However, when I run this in Jenkins, I get the following error:
+ mvn surefire-report:report test site
[INFO] Scanning for projects...
[INFO]
[INFO] ---< [MY-PROJECT] >----
[INFO] Building [MY-PROJECT] 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ...etc...
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.ExampleTest
No features found at [classpath:com/example]
0 Scenarios
0 Steps
0m0.000s
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.442 s - in com.example.ExampleTest
It looks like it can't find my classpath... but it works locally, so I can't see why it would fail on Jenkins; in any case; here's my POM File:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>[MY-PROJECT]</groupId>
<artifactId>[MY-PROJECT]</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>cucumber.api.cli.Main</argument>
<argument>--plugin</argument>
<argument>json:${project.build.directory}/cuke-results.json</argument>
<argument>--glue</argument>
<argument>com.example</argument>
<argument>--strict</argument>
<argument>${basedir}/src/test/java/com/example</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
</dependencies>
</project>

Related

Maven Surefire Plugin version 3.0.0-M5 ignored include test

I have configured a surefire plugin in pom.xml to run a Testsuite.
With version 3.0.0-M3 works all fine, but if I switch to version 3.0.0-M5 test will igore and run 0 tests.
What can I do? What I am doing wrong?
Maven Log with version M3:
16:35:00 [INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) # bitone-appium ---
16:35:01 [INFO]
16:35:01 [INFO] -------------------------------------------------------
16:35:01 [INFO] T E S T S
16:35:01 [INFO] -------------------------------------------------------
16:35:01 [INFO] Running Android All Tests Suite
.
.
.
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 77.921 s - in Android All Tests Suite
16:36:19 [INFO]
16:36:19 [INFO] Results:
16:36:19 [INFO]
16:36:19 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
16:36:19 [INFO]
16:36:19 [INFO]
Maven Log with version M5:
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # xxxx-appium ---
[INFO] Building jar: /Users/xxxx/Projects/xxxx-testautomatisierung/xxxx-appium/target/xxxx-appium-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # xxxx-appium ---
[INFO] Installing ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.563 s
[INFO] Finished at: 2022-01-10T15:26:33+01:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
part of pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
<maven-clean.version>2.5</maven-clean.version>
<maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version>
<maven-javadoc.version>3.2.0</maven-javadoc.version>
<junit5.jupiter.version>5.8.1</junit5.jupiter.version>
<junit5.jupiter.suite.version>1.7.0</junit5.jupiter.suite.version>
<junit5.junit.platform.launcher>1.8.1</junit5.junit.platform.launcher>
<junit5.junit.platform-runner>1.8.1</junit5.junit.platform-runner>
<junit5.junit.platform-commons>1.8.1</junit5.junit.platform-commons>
<junit5.junit.suite-engine>1.8.1</junit5.junit.suite-engine>
<junit5.junit.platform-params>5.8.1</junit5.junit.platform-params>
<appium-java-client.version>7.5.1</appium-java-client.version>
<selenium-java.version>3.141.59</selenium-java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.jupiter.version}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit5.junit.platform.launcher}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit5.junit.platform-runner}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>${junit5.junit.platform-commons}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit5.junit.platform-params}</version>
<!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-engine</artifactId>
<version>${junit5.junit.suite-engine}</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${appium-java-client.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium-java.version}</version>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>${testsuite}.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
Maven command:
mvn clean install -Dtestsuite=AndroidAllTestsSuite
AndroidAllTestSuite.java:
import android.login.LoginTest;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SuiteDisplayName;
#Suite
#SelectClasses({
LoginTest.class
})
#SuiteDisplayName("Android All Tests Suite")
public class AndroidAllTestsSuite {
}
LoginTest.java:
import org.junit.jupiter.api.*;
public class LoginTest {
#Test
public void loginTest() {
Assertions.assertTrue(true);
}
}
Try to declare surefire-plugin in this way:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
or this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
Some references
https://maven.apache.org/surefire/maven-surefire-plugin/examples/providers.html
https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-junit47
https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-junit-platform
Thank you, I could solve the problem.
I had been used #BeforeClass (JUnit 4) and Jupiter (JUnit5).
That was my problem.

Junit test cases not running using maven

I am trying to run a maven test for the following pom. But no tests re getting picked up. Though in the maven tests its showing that the test is being compiled. I am using JUnit 4.12. I tried several things and found out that the parent pom is causing the issues. If I remove the parent pom and give its own group id and artifact Id it's working.
Can some please explain to me why it's not working with the parent pom and provide a solution for it.
<parent>
<groupId>com.test</groupId>
<artifactId>test-parent</artifactId>
<version>20.6.0</version>
</parent>
<artifactId>ai_one_click</artifactId>
<name>one_click</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>data_model</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<configuration>
<includes> <include>**/Test1.java</include> </includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # ai_one_click ---
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-cli) # ai_one_click ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to one_click\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-cli) # ai_one_click ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
I tried with various maven commands
clean surefire:test
clean test
clean -D maven.test.failure.ignore=true compiler:testCompile surefire:test
test -Dtest=Test1

com.thoughtworks.xstream.converters.ConversionException while running jmeter script using maven eclipse

I have integrated my jmeter script with maven. I have jmeter plugin manager also. While running it, i am getting java.lang.IllegalArgumentException which is resulting into above exception. I have added dependency for jmeter plugin manager and xstream but still i am getting same error.
exactly same kind of issue has been discussed here, but the content now has been removed.
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/194
pom file -
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test_framework</groupId>
<artifactId>api_test_plan</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dkc_api_test_plan</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<ThreadCount.thread1>10</ThreadCount.thread1>
</properties>
<build>
<plugins>
<!-- jmeter plugin to run jmeter through maven build -->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<resultsFileFormat>xml</resultsFileFormat>
<generateReports>false</generateReports>
<testResultsTimestamp>false</testResultsTimestamp>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.3.1</artifact>
</jmeterExtensions>
<!-- inputFile>${project.build.directory}/jmeter/results/CreateOrderLoadTest.jtl</inputFile -->
</configuration>
</plugin>
<!--surefire plugin to generate html reports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<outputFolder>${project.build.directory}/target/surefire-reports</outputFolder>
<printReport>true</printReport>
<exportAll>true</exportAll>
</configuration>
</plugin>
<!-- plugin> <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-analysis-maven-plugin</artifactId>
<version>1.0.4</version> <configuration> <source>${project.build.directory}/jmeter/results/dkc_sales.jtl</source>
</configuration> <executions> <execution> <id>create-html-report</id> <phase>verify</phase>
<goals> <goal>analyze</goal> </goals> </execution> </executions> </plugin -->
</plugins>
<!-- https://mvnrepository.com/artifact/junit/junit -->
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/kg.apc/jmeter-plugins-manager <dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-manager</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
</project> ```
-------------------------------------------------------
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO]
[INFO] Executing test: myFile.jmx
[INFO] Starting process with:[java, -Xms512M, -Xmx512M, -jar, ApacheJMeter-4.0.jar, -d, D:\Projects\....
[INFO] Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'D:\Projects\\target\jmeter\testFiles\myFile.jmx', missing class com.thoughtworks.xstream.converters.ConversionException:
[INFO] ---- Debugging information ----
[INFO] cause-exception : com.thoughtworks.xstream.converters.ConversionException
[INFO] cause-message :
[INFO] first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
[INFO] class : org.apache.jmeter.save.ScriptWrapper
[INFO] required-type : org.apache.jorphan.collections.ListedHashTree
[INFO] converter-type : org.apache.jmeter.save.ScriptWrapperConverter
[INFO] path : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/hashTree[5]/hashTree[4]/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
[INFO] line number : 3610
[INFO] version : 4.0 r1823414
[INFO] -------------------------------
[INFO] Completed Test: D:\Projects\Project_Name\api_test_plan\target\jmeter\testFiles\myFile.jmx
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.003 s
[INFO] Finished at: 2019-04-19T12:53:28+05:30
[INFO] Final Memory: 38M/282M
[INFO] ------------------------------------------------------------------------
[INFO] Shutdown detected, destroying JMeter process...**strong text**
Don’t use pom dependencies as you did in:
kg.apc:jmeter-plugins:pom:1.3.1
It should work

why maven-failsafe-plugin doesn't show serenity tests executed?

I setup a basic project using Serenity and I am having issues displaying results when I run mvn clean verify
[INFO] --- maven-failsafe-plugin:2.20:integration-test (default) # functional-tests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running starter.SmokeTestSuite
Feature: Booking
#Smoke
Scenario Outline: Book a reservation # src/test/resources/features/book/booking_creation.feature:4
Given an agent with role "ADMIN" has logged in
Examples:
#Smoke
Scenario Outline: Book a reservation # src/test/resources/features/book/booking_creation.feature:19
Started InternetExplorerDriver server (32-bit)
3.13.0.0
Listening on port 11642
Only local connections are allowed
Sep 10, 2018 7:50:29 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Given an agent with role "ADMIN" has logged in # LoginSteps.agent_has_logged_in(String)
1 Scenarios (1 passed)
1 Steps (1 passed)
0m18.568s
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.681 s - in starter.SmokeTestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
These are some facts I have from this issue:
The SERENITY and TEST STARTED ascii art is not being displayed, but the TEST FAILED ascii art is
The test is running (as you can see in the log, it shows 1 scenario passed), the problem is it is not showing the number of tests executed
It doesn't matter if the test passes or fails, it still won't show anything
The runner class is runner/SmokeTestSuite.java
This is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>functional-tests</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>functional tests</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>1.9.26</serenity.version>
<serenity.maven.version>1.9.26</serenity.maven.version>
<serenity.cucumber.version>1.9.8</serenity.cucumber.version>
<encoding>UTF-8</encoding>
<tags></tags>
<parallel.tests>4</parallel.tests>
<webdriver.base.url></webdriver.base.url>
</properties>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<include>**/*TestSuite.java</include>
</includes>
<!--
<systemPropertyVariables>
<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
</systemPropertyVariables>
-->
<parallel>classes</parallel>
<threadCount>${parallel.tests}</threadCount>
<forkCount>${parallel.tests}</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I appreciate any help, thanks!
I had the same problem with a similar project. The reason why surefire didn't count the serenity test results was because the POM contained JUnit and TestNG artifacts. The TestNG artifact was added via a parent POM.
After I removed the TestNG dependency the report showed the number of tests executed.
This doesn't answer you question as to why maven-failsafe-plugin doesn't show tests executed, but I have the same problem and needed to fail the build if tests failed.
The tests run but executions are not reported:
Reports view generated with 288 stories (of which 1 pending) containing 2463 scenarios (of which 1 pending)
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 23,875.336 sec
I upgraded the Serenity, JBehave and Selenium dependencies with no luck.
I have resorted to using the serenity-maven-plugin:check goal to fail the build (instead of the maven-failsafe-plugin) during the verify phase:
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
...
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
Which results in a build failure as required:
[INFO] --- serenity-maven-plugin:1.9.45:check (default) # project-testing ---
[INFO] Checking Serenity test results
[INFO] ----------------------
[INFO] SERENITY TEST OUTCOMES
[INFO] ----------------------
[INFO] - Tests executed: 2628
[INFO] - Tests passed: 1823
[INFO] - Tests failed: 48
[INFO] - Tests with errors: 757
[INFO] - Tests pending: 0
[INFO] - Tests compromised: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.serenity-bdd.maven.plugins:serenity-maven-plugin:1.9.45:check (default) on project project-testing: An error occurred in the Serenity tests -> [Help 1]

Maven can't read my Cucumber Test

I'm currently receiving this log when running 'mvn test'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Envirosite-Regression 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Envirosite-Regression ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\christian.nuval\Envirosite-Regression\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Envirosite-Regression ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Envirosite-Regression ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Envirosite-Regression ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Envirosite-Regression ---
[INFO] Surefire report directory: C:\Users\christian.nuval\Envirosite-Regression\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.EnvirositeRegression.bdd.IssueTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator#7a46a697
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.385 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.374 s
[INFO] Finished at: 2016-07-21T16:32:18+08:00
[INFO] Final Memory: 12M/225M
[INFO] ------------------------------------------------------------------------
My pom.xml looks like this :
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.EnvirositeRegression.bdd</groupId>
<artifactId>Envirosite-Regression</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Envirosite-Regression</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openqa.selenium.core</groupId>
<artifactId>selenium-core</artifactId>
<version>1.0-20080914.225453</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>cucumber-tests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
My IssueTest.java looks like this :
package com.EnvirositeRegression.bdd;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
format = { "pretty", "html:target/cucumber" },
glue = "com.EnvirositeRegression.bdd",
features = "SiteSearchTool.feature"
)
public class IssueTest {
}
I don't know why the IssueTest.Java is not properly read even though I added it as an inclusion in my build configuration of maven-surefire-plugin.
Please advise.
Your logs are showing SUCCESS with no executed tests because there are no tests to run i.e. no tests are written in your IssueTest. Try an example test-case, then run mvn test.
public class IssueTest {
#Test
public void exampleReturnsTrue()
{
assertTrue("This will succeed.", true);
}
}
A side-note:
If your tests are located where there supposed to be (./src/tests/java/); I suppose your pom.xml could do without the <configuration> [...] </configuration> clause, so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
You have 2 configuration tags one after another - try to remove one of them and see. Also, it's a good idea in cases like that to debug maven execution with -X flag.

Categories

Resources