TestEngine with ID 'junit-jupiter' failed to discover tests after maven repackage - maven-plugin

I started to receive TestEngine with ID 'junit-jupiter' failed to discover tests error while running my tests by maven after configuring my plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
Without this I was able to run all the tests without any issue by maven. I needed to add this to solve another issue but then I started to receive this error for my integration tests. When I enable log for maven I noticed that it cannot find domain classes(they are not test classes).
Caused by: java.lang.ClassNotFoundException: com.mypackage.domain.MyDomainObject
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 42 more
What can cause this issue any ideas?

Related

Proper setup for pitest-maven report-aggregate goal

folks!
I've tried to use the pitest-maven plugin in my Maven / Java project and it is apparently failing to generate an aggregated report (taking into consideration that I have a multi-module project).
I gather some information from the official website and from several other sources, however, none of them was really helpful to define the proper configuration for this scenario.
In a nutshell, my structure looks like:
Parent-Project
Child A
Child B
Child ...
Child N
In some of the submodules, it does make sense to have a pi-test being executed, others not. So to say, my configuration in general is.
Parent-module pom:
<profile>
<id>run-pitest</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.2</version>
<configuration>
<outputFormats>
<param>HTML</param>
<param>XML</param>
</outputFormats>
<!--<historyInputFile>${project.basedir}/pitHistory.txt</historyInputFile>-->
<!--<historyOutputFile>${project.basedir}/pitHistory.txt</historyOutputFile>-->
<mutators>
<mutator>CONDITIONALS_BOUNDARY</mutator>
<mutator>MATH</mutator>
<mutator>INCREMENTS</mutator>
<mutator>NEGATE_CONDITIONALS</mutator>
</mutators>
<verbose>true</verbose>
<exportLineCoverage>true</exportLineCoverage>
<testPlugin>testng</testPlugin>
<!--<reportsDirectory>${project.build.directory}/pit-reports</reportsDirectory>-->
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>site</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
</plugin>
</plugins>
</build>
</profile>
Child project that has mutations:
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<configuration>
<mutationThreshold>80</mutationThreshold>
<exportLineCoverage>true</exportLineCoverage>
</configuration>
</plugin>
</plugins>
And, finally, when I try to execute the phase site (as defined in the parent) even after I executed a clean install that created the files such as linecoverage.xml and mutations.xml, I'm getting this error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.820 s
[INFO] Finished at: 2018-04-06T13:20:47+02:00
[INFO] Final Memory: 35M/514M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.3.2:report-aggregate (report) on project my-parent: An error has occurred in PIT Test Report report generation. Failed to build: no lineCoverageFiles have been set -> [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.
...
Does any of you have a clue if I did a bad configuration or if there is a better way to do any part of this setup?
It seems that you are running into several problems at once :
When running report-aggregate the plugin analyze the dependencies of the module it
runs in and expect everyone of them to have linecoverage.xml and a mutations.xml file. You have to have a submodule dedicated to report aggregation, and you should run report-aggregate only in this submodule.
report-aggregate can't deal with timestamped reports, it must be disabled
I couldn't make it work with the site phase. Not sure if it's a bug in the plugin or if I missed something (keeping the default phase works, but you need to get the report somehow, it won't be in the site).
Putting it all together :
in parent-module pom:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.2</version>
<configuration>
<outputFormats>
<param>HTML</param>
<param>XML</param>
</outputFormats>
<!-- omitting mutators, testPlugin and verbose for brevity -->
<exportLineCoverage>true</exportLineCoverage>
<!--
it's currently not possible to aggregate timestamped
reports, so it must be disabled.
-->
<timestampedReports>false</timestampedReports>
</configuration>
<executions>
<execution>
<!--
Use an id to disable it in some submodules
-->
<id>pitest-mutation-coverage</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
<!--
NO report-aggregate here. Most of the time you don't
want it to run.
-->
</executions>
</plugin>
</plugins>
</pluginManagement>
<!-- NO pitest here since its use will vary per submodule -->
</build>
in submodule with mutation :
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<!--
You can put configuration here, but IMOHO it's better to have it
in the parent pom. (so I leave it out here)
-->
</plugin>
</plugins>
in the submodule generating the report :
<!--
Only include submodules where `mutationCoverage` is run.
-->
<dependencies>
<dependency>
<groupId>you.groupId</groupId>
<artifactId>submodule-A</artifactId>
</dependency>
<dependency>
<groupId>you.groupId</groupId>
<artifactId>submodule-B</artifactId>
</dependency>
</dependencies>
and also
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<executions>
<!--
Using the execution id to change its phase to none disables
mutationCoverage in this module.
(not sure it's the best way to do it, but as long as it doesn't
run you should be fine)
-->
<execution>
<id>pitest-mutation-coverage</id>
<phase>none</phase>
</execution>
<execution>
<id>report</id>
<!--
Keep default phase here.
-->
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

Integration testing with Maven, Protractor and Selenium WebDriver

We develop a web application that uses Java on the back-end and Angular for the UI, with Maven as the build system.
I've been trying to set up automated integration testing with Protractor, and after loads of Googling/StackOverflowing still can't figure out how the end-2-end configuration can be achieved.
Node.js/NPM installation (failed)
I've tried using frontend-maven-plugin to handle Node.js and NPM installation, but since we're behind a corporate firewall, it doesn't seem possible to download anything directly. It could download Node from our Artifactory though, but then failed on NPM download (I don't understand why it even downloads it as it's a part of Node package). Anyway, I gave up on this idea and decided to use Node installed locally.
Starting Tomcat
Starting/stopping a Tomcat instance for e2e testing is handled nicely by
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>${tomcat.manager.url}</url>
<path>/</path>
<server>Tomcat</server>
</configuration>
<executions>
<!-- Starting Tomcat -->
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<!-- Fork the process, otherwise the build will be blocked by the running Tomcat -->
<fork>true</fork>
<port>${tomcat.port}</port>
<systemProperties>
<!-- We want to use the 'e2e' profile for integration testing -->
<spring.profiles.active>e2e</spring.profiles.active>
</systemProperties>
</configuration>
</execution>
<!-- Stopping Tomcat -->
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
Using WebDriver (failed)
I managed to start WebDriver, but the problem is it's blocking any further execution:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<!-- Start webdriver -->
<execution>
<id>start-webdriver</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>webdriver-manager</executable>
<arguments>
<argument>start</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Running Protractor
Given that Node.js is installed and WebDriver is running, this shouldn't be a problem. But as I failed to start WebDriver so that it continues execution, this is blocked.
Any advice how the WebDriver can be managed (started/stopped)?
Adding directConnect: true to the Protractor config file solves the issue of starting/stopping the WebDriver (as suggested by Nick). In that case any explicit control of the WebDriver has to be removed from the POM.
Available parameters are explained in detail in the reference configuration file.

How to organize build with foundation for apps and Maven?

I have a project that has :
Java server that is a WAR deployed on Tomcat. It includes all the Java code of my entities, DAO, Service and API.
JS client built with Foundation for Apps. It includes Angular JS, Bower, Gulp and Sass.
I'm trying to organize the build process of this project but I have difficulties to implement it.
As said in this post How to organize full build pipeline with Gulp, Maven and Jenkins, I tried to use the frontend-maven-plugin but without success.
I have the following error :
`
[ERROR]
[ERROR] events.js:141
[ERROR] throw er; // Unhandled 'error' event
[ERROR] ^
[ERROR] Error: client\assets\scss\_settings.scss
[ERROR] Error: File to import not found or unreadable: helpers/functions
[ERROR] Parent style sheet: C:/Dev/Code/Porteo/fr.porteo.parent/fr.porteo.jersey/porteo_fa/client/assets/scss/_settings.scss
[ERROR] on line 32 of client/assets/scss/_settings.scss
[ERROR] >> #import "helpers/functions";
[ERROR] ^`
It would seem there is a problem with the _settings.css file. He don't recognize the tag #import. But where does the problem come from?
It's surely from maven and the frontent-maven-plugin but how to fix it?
Here my pom.xml with plugin dependencies and executions (only npm start is necessary to run the foundation project) :
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>0.0.29</version>
<configuration>
<workingDirectory>my_foundation_project</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v5.3.0</nodeVersion>
<npmVersion>3.3.12</npmVersion>
</configuration>
</execution>
<execution>
<id>npm start</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>start</arguments>
</configuration>
</execution>
</executions>
</plugin>
So, Have you any solutions or a better way to implement these two applications?
Issue with similar symptoms - caused by bower permissions mismatch

Resolving Izpack artifacts using maven dependency

I have Izpack installer which packs a pre-configured server and installs in target directory. This server is around 500Mb. Currently I have checked in this src/main/resources folder of installer maven project.But having this big server in git is making the git pulls very slow. So i am planning to keep this server as maven artifact in nexus and add its dependency to installer maven project. This way i can create a maven profile to pull this server from nexus on demand. I am yet to figure out how to copy this dependency to staging folder using a maven plugin(any help would be greatly appreciated). My question here, is it a right approach? or is there any better way to do this. Thanks in advance.
You can use the maven dependency plugin to copy a dependeny to a specific folder.
You can use it to either copy all dependencies or even unpack those dependencies.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<outputDirectory>${izpack.staging}/content/ninjolibs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
This is what i did. I uploaded wso2.zip to nexus as zip artifact and configured pom.xml of my installer module to use this dependency.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-binaries</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wso2</groupId>
<artifactId>wso2is</artifactId>
<version>5.0.0</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>src/main/resources/wso2/binary</outputDirectory>
<destFileName>wso2is-5.0.0.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

build-helper-maven-plugin report error sources is missing

I try to use build-helper-maven-plugin 1.9 to add integration test folder, Pom shows below:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/integrate/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
the maven version is 3.2.2, when I run mvn build-helper:add-source, it throws errors below:
[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (default-cli) on project test: The parameters 'sources' for
goal org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source are missing or invalid -> [Help 1]
appreciate any help
Fix it in Eclipse with install APT M2E Connector, m2e Connector for build-helper-maven-plugin.
now the folder shows in Eclipse correctly.

Resources