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]
Related
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
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>
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
The "mvn test" compiles my test case, but it does not run it:
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # test-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to my-server\backend\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) # my-server ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
pom.xml properties:
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<junit.jupiter.version>5.0.0</junit.jupiter.version>
<junit.vintage.version>${junit.version}.0</junit.vintage.version>
<junit.jupiter.version>5.0.0</junit.jupiter.version>
<junit.platform.version>1.0.0</junit.platform.version>
</properties>
Build settings:
<build>
<finalName>my-server</finalName>
<testSourceDirectory>src/test</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Dependencies:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
The test class is in the testSourceDirectory directory, its name begins with "Test", and it has the #Test annotation.
I suspect that the tests are not executed because the packaging is "war" instead of "jar". But I cannot change that - there is a single "packaging" setting for the whole project, and it must be "war" because it is really a web app.
So how do run my tests, and keep the "war" packaging at the same time?
UPDATE After adding the suggessted surefire provider, the test fails. surefire-reports/*.dump file shows this traceback:
# Created on 2017-12-17T10:58:50.171
java.lang.NoSuchMethodError: org.apache.maven.surefire.report.RunListener.testSetStarting(Lorg/apache/maven/surefire/report/ReportEntry;)V
at org.junit.platform.surefire.provider.JUnitPlatformProvider.invokeSingleClass(JUnitPlatformProvider.java:137)
at org.junit.platform.surefire.provider.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:126)
at org.junit.platform.surefire.provider.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:105)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407)
JUnit 5 will works fine with following combination of dependencies and plugin version, both in JDK 8/11.
Dependency
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
Build
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
Seems like the signature of org.apache.maven.surefire.report.RunListener.testSetStarting was changed in 2.21.0.
junit-platform-surefire-provider depends on surefire-api.2.19.1, so it calls testSetStarting with an instance of ReportEntry where the method now accepts TestSetReportEntry.
The dependency is upgraded to 2.21.0 so we'll just have to wait for the next release of junit 5.
I have built current master branch of junit,and can confirm that junit-platform-1.2.0-SNAPSHOT and juniper-5.2.0-SNAPSHOT works as expected.
I'm currently building a new package for Hibernate project Hibernate Search and I need to run some unit tests in a managed WildFly container using Arquillian. When I use the command mvn clean install, I got the below error :
org.jboss.arquillian.container.spi.ConfigurationException: jbossHome '${project.build.directory}/node1/wildfly-${org.wildfly}' must exist
This property is configured in ./src/test/resources/arquillian.xml. Having this exception is "normal" because it has reason: the target folder ./target/node1/wildfly-10.0.0.Final does not exist. However, this path should have been configured in maven pom.xml. So I try to run maven install without tests :
Mincongs-MBP:gsoc-hsearch mincong$ mvn clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Search - JSR352 5.6.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # hs-jsr352 ---
[INFO] Deleting /Users/mincong/Documents/GitHub/gsoc-hsearch/target
[INFO]
[INFO] --- dependencypath-maven-plugin:1.1.1:set (set-all) # hs-jsr352 ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/classes
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Some input files use or override a deprecated API.
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # hs-jsr352 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) # hs-jsr352 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hs-jsr352] in [/Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/webapp]
[INFO] Webapp assembled in [113 msecs]
[INFO] Building war: /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO]
[INFO] --- maven-dependency-plugin:2.6:unpack (unpack) # hs-jsr352 ---
[INFO] Configured Artifact: org.wildfly:wildfly-dist:10.0.0.Final:zip
[INFO] Unpacking /Users/mincong/.m2/repository/org/wildfly/wildfly-dist/10.0.0.Final/wildfly-dist-10.0.0.Final.zip to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/node1 with includes "" and excludes ""
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (configure-as-node-node1) # hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/mincong/Documents/GitHub/gsoc-hsearch/src/wildflyConfig
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # hs-jsr352 ---
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/pom.xml to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.274 s
[INFO] Finished at: 2016-06-18T16:01:51+02:00
[INFO] Final Memory: 36M/280M
[INFO] ------------------------------------------------------------------------
And I noticed that :
Tests are located at step 7
WildFly installation is located at step 9
So tests are launched before runtime setup. Therefore, my questions are:
How to make sure the managed runtime WildFly 10 get unpacked before the tests ?
For my test class DeployementTest, is it part of the pre-integration / integration test ?
If yes, should I use an additional module for it ?
I'm really new on all these fields. Please forgive me if I'm mixing words up or asking stupid questions ... Thanks for your help !
Here're some related files that might be helpful :
./pom.xml
./src/test/resources/arquillian.xml
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
./pom.xml
<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>io.github.mincongh</groupId>
<artifactId>hs-jsr352</artifactId>
<version>5.6.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Hibernate Search - JSR352</name>
<description>New implementation mass-indexer using JSR 352</description>
<properties>
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
<org.wildfly>10.0.0.Final</org.wildfly>
<org.wildfly.arquillian>8.2.1.Final</org.wildfly.arquillian>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>perf</id>
<properties>
<org.hibernate.search.enable_performance_tests>true</org.hibernate.search.enable_performance_tests>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.3.Final</version>
<!--
<exclusions>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- Not sure the version of EJB, this is provided by GlassFish -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${org.wildfly.arquillian}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j-jboss-logmanager</artifactId>
</exclusion>
<!-- This exclusion is needed to be able to setup the project in Windows:
it otherwise includes transitive dependency to the JDK JConsole -->
<exclusion>
<artifactId>wildfly-patching</artifactId>
<groupId>org.wildfly</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<!-- Allows to find the absolute path to dependencies -->
<groupId>org.bitstrings.maven.plugins</groupId>
<artifactId>dependencypath-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>set-all</id>
<goals>
<goal>set</goal>
</goals>
<configuration>
<propertySets>
<propertySet>
<includes>
<include>org.jboss.byteman:byteman:jar</include>
</includes>
</propertySet>
</propertySets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<systemPropertyVariables>
<!-- See HSEARCH-1444 -->
<hibernate.service.allow_crawling>false</hibernate.service.allow_crawling>
<com.sun.management.jmxremote>true</com.sun.management.jmxremote>
<org.hibernate.search.enable_performance_tests>${org.hibernate.search.enable_performance_tests}</org.hibernate.search.enable_performance_tests>
</systemPropertyVariables>
<additionalClasspathElements>
<!-- Needed by Byteman to load the agent on demand -->
<additionalClasspathElement>${jdk-toolsjar}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${org.wildfly}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1</outputDirectory>
</artifactItem>
<!--
<artifactItem>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-modules</artifactId>
<version>${project.version}</version>
<classifier>wildfly-10-dist</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}/modules</outputDirectory>
</artifactItem>
-->
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<!-- Copy the AS configuration files so we can use our custom configurations -->
<execution>
<id>configure-as-node-node1</id>
<!-- <phase>pre-integration-test</phase> -->
<phase>integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/src/wildflyConfig</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
./src/test/resources/arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate Search, full-text search for your domain model
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<!-- Uncomment in order to inspect deployments -->
<!--
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
-->
<group qualifier="Grid" default="true">
<container qualifier="container.active-1" mode="suite" default="true">
<configuration>
<property name="jbossHome">${project.build.directory}/node1/wildfly-${org.wildfly}</property>
<!-- Needed for JMS tests -->
<property name="serverConfig">standalone-full-testqueues.xml</property>
<property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xmx512m -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property>
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property -->
</configuration>
</container>
</group>
</arquillian>
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
package org.hibernate.search.jsr352;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
#RunWith(Arquillian.class)
public class DeploymentTest {
#Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(true, "io.github.mincongh")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/mass-index.xml");
System.out.println(war.toString(true));
return war;
}
#Test
public void startJob() {
// TODO: add tasks here
}
}
Perhaps you're mixing up Maven Surefire and Failsafe plugins.
DeploymentTest above is a unit test, not an IT test, that will be executed by Surefire. Therefore, if you're looking to unpack WildFly using maven-dependency-plugin, you'll need to bind unpack to a phase such as <phase>process-test-classes</phase>, that will execute before Surefire does in the test phase.
Maven Lifecycle Reference:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference