I'm trying to use Allure - framework to generate a report for my Rest Assured tests. I run tests with mvn test -Dtest=${MyClass} command and all tests pass, and then generate a report using mvn allure:report. After all, I start jetty server mvn jetty:run and when I navigate to localhost I can see a completely empty report (there is only template with no info).
This seems to be a misconfiguration problem, but what am I doing wrong? Here 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.testtask</groupId>
<artifactId>com.testtask</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version>
<aspectj.version>1.9.3.RC1</aspectj.version>
<jetty.maven.plugin.version>9.3.9.v20160517</jetty.maven.plugin.version>
<allure.maven.version>2.10.0</allure.maven.version>
<rest.assured.version>3.3.0</rest.assured.version>
<allure.rest.assured.version>2.10.0</allure.rest.assured.version>
<allure.testng.version>2.10.0</allure.testng.version>
<junit.version>4.12</junit.version>
</properties>
<build>
<pluginManagement>
<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>
<!--Running tests-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<!--Server to view the report-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.plugin.version}</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
<stopKey>stop</stopKey>
<stopPort>1234</stopPort>
</configuration>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!--Rest Assured section-->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest.assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>${rest.assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>${rest.assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${rest.assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-rest-assured</artifactId> <!--generates attachment for allure-->
<version>${allure.rest.assured.version}</version>
</dependency>
<!--Allure TestNG Dependency-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.testng.version}</version>
</dependency>
<!-- Java 6 = JAX-B Version 2.0 -->
<!-- Java 7 = JAX-B Version 2.2.3 -->
<!-- Java 8 = JAX-B Version 2.2.8 -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
mvn allure:report
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.testtask:com.testtask >----------------------
[INFO] Building com.testtask 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- allure-maven:2.10.0:report (default-cli) # com.testtask ---
[INFO] Allure installation directory C:\PRJ\X\PetAPI/.allure
[INFO] Try to finding out allure 2.8.1
[INFO] Generate Allure report (report) with version 2.8.1
[INFO] Generate Allure report to C:\PRJ\X\PetAPI\target\site/allure-maven-plugin
[INFO] Found results directory C:\PRJ\X\PetAPI\target\allure-results
[INFO] Can't find information about categories.
[INFO] Generate report to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
Report successfully generated to C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Report generated successfully.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.631 s
[INFO] Finished at: 2019-03-16T18:48:34+04:00
[INFO] ------------------------------------------------------------------------
mvn jetty:run
...
[INFO] --- jetty-maven-plugin:9.3.9.v20160517:run (default-cli) # com.testtask ---
[INFO] Configuring Jetty for project: com.testtask
[INFO] Webapp source directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\PRJ\X\PetAPI\target\classes
[INFO] Logging initialized #7207ms
[INFO] Context path = /
[INFO] Tmp directory = C:\PRJ\X\PetAPI\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = null
[INFO] Webapp directory = C:\PRJ\X\PetAPI\target\site\allure-maven-plugin
[INFO] jetty-9.3.9.v20160517
[INFO] Started o.e.j.m.p.JettyWebAppContext#4a734c04{/,file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/,AVAILABLE}{file:///C:/PRJ/X/PetAPI/target/site/allure-maven-plugin/}
[INFO] Started ServerConnector#24841372{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started #12047ms
[INFO] Started Jetty Server
Solution found: it was necessary to add a dependency on TestNG
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
and remove the dependency on Junit.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
Currently an Allure report is generated correctly
Related
Java 8, maven compile issue on Jenkins
struggling for ages with this one. I can locally build, compile and test everything without a problem. I use same maven command as I use on my Jenkins. I wiped my .m2 folder so I have same empty repo and still everything fine.
This is the maven command I use:
(mvn) -U clean install -PTestExecutor -Dheadless=true -C
this is my POM:
<?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.xxx</groupId>
<artifactId>testing</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<cucumber.version>7.3.3</cucumber.version>
<selenium.version>4.1.4</selenium.version>
<awaitility.version>4.2.0</awaitility.version>
<assertj.version>3.22.0</assertj.version>
<commonsmodel.version>5.3.3</commonsmodel.version>
<maven.compiler.version>3.10.1</maven.compiler.version>
<maven.surefire.version>3.0.0-M6</maven.surefire.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<junit-jupiter-engine.version>5.8.2</junit-jupiter-engine.version>
<maven-cucumber-reporting.version>5.7.0</maven-cucumber-reporting.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter-engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jodah</groupId>
<artifactId>failsafe</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>TestExecutor</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter-engine.version}</version>
</dependency>
</dependencies>
<configuration>
<includes>
<includes>**/ExecutorTest.java</includes>
</includes>
</configuration>
</plugin>
<!--cucumber report plugin-->
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>
<executions>
<execution>
<id>generate-cucumber-reports</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Automation report</projectName>
<outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
<inputDirectory>${project.build.directory}/cucumber</inputDirectory>
<jsonFiles>
<param>**/*.json</param>
</jsonFiles>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
and this is the full error report on Jenkins output:
Executing Maven: -B -f /appl/xxx/jenkins/workspace/Customer_Portal/web-full-suite/pom.xml -s /appl/xxx/maven/apache-maven-3.3.9/conf/settings.xml -U clean install -PTestExecutor -Dheadless=true -C
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testing 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo/org/apache/maven/maven-core/3.1.0/maven-core-3.1.0.pom
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/plugins-release/org/apache/maven/maven-core/3.1.0/maven-core-3.1.0.pom
[WARNING] The POM for org.apache.maven:maven-core:jar:3.1.0 is missing, no dependency information available
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo/org/apache/maven/maven-plugin-api/3.1.0/maven-plugin-api-3.1.0.pom
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/plugins-release/org/apache/maven/maven-plugin-api/3.1.0/maven-plugin-api-3.1.0.pom
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:3.1.0 is missing, no dependency information available
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/plugins-release/io/cucumber/messages/maven-metadata.xml
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo/io/cucumber/messages/maven-metadata.xml
[INFO] Downloaded: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo/io/cucumber/messages/maven-metadata.xml (421 B at 20.6 KB/sec)
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:3.8.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo/org/apache/maven/maven/3.1.0/maven-3.1.0.pom
[INFO] Downloading: http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/plugins-release/org/apache/maven/maven/3.1.0/maven-3.1.0.pom
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.828 s
[INFO] Finished at: 2022-06-13T16:59:43+02:00
[INFO] Final Memory: 18M/152M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal on project testing: Could not resolve dependencies for project com.xxx:testing:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:3.0.0-M6 -> org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M6 -> org.apache.maven.shared:maven-common-artifact-filters:jar:3.1.1 -> org.apache.maven:maven-artifact:jar:3.1.0: Failed to read artifact descriptor for org.apache.maven:maven-artifact:jar:3.1.0: Could not find artifact org.apache.maven:maven:pom:3.1.0 in XXX-Repo (http://nlxxxxcv166.srvfarm4-eur.xxx-group.com:8081/artifactory/Maven_repo) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[JENKINS] Archiving /appl/xxx/jenkins/workspace/Customer_Portal/web-full-suite/pom.xml to com.xxx/testing/1.0-SNAPSHOT/testing-1.0-SNAPSHOT.pom
channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level /cucumber/cucumber.html to /appl/xxx/jenkins/jobs/Customer_Portal/jobs/web-full-suite/htmlreports/HTML_20Report
ERROR: Specified HTML directory '/cucumber/cucumber.html' does not exist.
Publishing Selenium report...
Copying the reports.
parsing resultFile cucumber/cucumber.html
Unable to parse cucumber/cucumber.html: java.io.IOException: org.xml.sax.SAXParseException; systemId: file:/appl/xxx/jenkins/jobs/Customer_Portal/jobs/web-full-suite/builds/160/seleniumReports/cucumber/cucumber.html; lineNumber: 1; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
Set result to FAILURE
Finished: FAILURE
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
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 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.
I'm trying to use Lombok with Maven and VRaptor on IntelliJ but it doesn't work.
I already read some info in stackoverflow but none solved my problem, i already enabled the Annotation Processor in Intellij but still nothing.
I tryied to compile it from command-line too (Windows) and didn't work.
I also tryed to create another project without maven and add the library, create some classes for test and it works, compile and run perfectly.
Any help?
The project has only 2 class, 1 entity and 1 controller
Here is my 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>razor</groupId>
<artifactId>controle-de-ponto</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<description>Um sistema de controlo de ponto</description>
<repositories>
<repository>
<id>projectlombok.org</id>
<url>http://projectlombok.org/mavenrepo</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<weld.version>2.1.2.Final</weld.version>
</properties>
<dependencies>
<dependency>
<groupId>br.com.caelum</groupId>
<artifactId>vraptor</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>0.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>2.1.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<version>2.1.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<!-- uncomment this line on app servers -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-jpa</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-java8</artifactId>
<version>4.0.0.Final</version>
</dependency>
</dependencies>
<build>
<finalName>controle-de-ponto</finalName>
<!--<outputDirectory>/Users/turini/Documents/workspace/vraptor4/vraptor-blank-project/src/main/webapp/WEB-INF/classes</outputDirectory>-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Error when i try to compile:
[INFO] ------------------------------------------------------------------------
[INFO] Building controle-de-ponto 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # controle-de-ponto ---
[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # controle-de-ponto ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\Kennedy\Desktop\controle-de-ponto\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Kennedy/Desktop/controle-de-ponto/src/main/java/br/com/caelum/vraptor/controller/IndexController.java:[37,16] cannot find symbol
symbol: method setNome(java.lang.String)
location: variable usuario of type org.razor.cponto.beans.Usuario
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.167 s
[INFO] Finished at: 2015-02-04T13:41:01-02:00
[INFO] Final Memory: 17M/204M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project controle-de-ponto: Compilation failure
[ERROR] /C:/Users/Kennedy/Desktop/controle-de-ponto/src/main/java/br/com/caelum/vraptor/controller/IndexController.java:[37,16] cannot find symbol
[ERROR] symbol: method setNome(java.lang.String)
[ERROR] location: variable usuario of type org.razor.cponto.beans.Usuario
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This might work
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
Latest versions:
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin
https://mvnrepository.com/artifact/org.projectlombok/lombok
This should work as is, and has nothing to do with IntelliJ idea. But I would:
make sure the #Data annotation is the lombok one
remove the repository definition (maven central is fine)
use a recent lombok version (1.16.0 as of this writing)
rebuild (mvn clean package)
I think the lombok jar is not found by maven in your case or that you might have another #Data.
Try this dependency
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
In the projectId tag, try to replace projectlombok.org with org.projectlombok
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
this should solve the problem same issue on my vs code
You need add lombok plugin:
<build>
<plugins>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>