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.
Related
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.
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'm aware that there are multiple threads going around in regards to this I have tried for up to 3 hours so I apologise for the repetition.
All I want to do is run mvn test to have it run the Junit 5 Tests. Pressing Run on IntelliJ works but mvn test in the terminal does not.
File structure is below -
https://user-images.githubusercontent.com/37623164/64642711-53cf1d80-d452-11e9-9764-849d73fcc5c9.png
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.petrego</groupId>
<artifactId>PetRego</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>PetRego</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
</project>
Returned Result in Logs -
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.petrego:PetRego >-------------------------
[INFO] Building PetRego 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # PetRego ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # PetRego ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # PetRego ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/639603/projects/PetRego/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # PetRego ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # PetRego ---
[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
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.704 s
[INFO] Finished at: 2019-09-11T05:02:30+10:00
[INFO] ------------------------------------------------------------------------
In general, the first thing you should do is check if there are newer versions of plugins.
Upgrading surefire should fix your issue, see https://maven.apache.org/surefire/maven-surefire-plugin/
As #AKSW suggested in the questions there is an incorrect import.
I was importing org.junit.Test (Junit4) when I should been importing JUnit5 org.junit.jupiter.api.Test (JUnit5)
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'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