I've been reading online for days and days but i'm still not sure i got the answer I need, or a way to fix this problem.
I have a set of Java tests that are using JUnit5 and Selenium.
This was my pom.xml file:
<?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.ces.cursos.timetracker</groupId>
<artifactId>primerosScripts3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>primerosScripts3</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
With it, I was able to run all tests successfully by selecting the package and going into "Run As > JUnit tests"
Now I want to create test suites to organize my tests.
I created a new package, and created a new class inside it with the following code:
package suites;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
import com.tests.Testing.Test1;
import com.tests.Testing.Test2;
#Suite
#SelectClasses({Test1.class, Test2.class})
public class Suite1 {
}
My first problem was that the #Suite and #SelectClasses annotations were not recognized. I had to add the following dependency to my pom.xml file to be able to use them:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
Now, when I try to run this suite, I get the "No tests found with test runner JUnit 5" error.
I have a strong suspicion this has to do with my dependencies and JUnit versions, but after reading and reading online I'm not able to understand exactly what I need to do.
I'm a beginner so that might be why i'm having trouble understanding where to go next.
I am trying to run tests in a project with Apache Maven 3.8.3, JDK 14, JUnit 5.8.1, jqwik 1.5.6
I'm using IntelliJ IDEA 2021.2.3 (Community Edition)
The libraries must be correctly imported but it still doesn't work.
When I try to run simple tests I 'm getting the following error message:
"Internal Error occurred.
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests"
Here is the pom.xml file. I'd appreciate any advice and thanks in advance!
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>
<groupId>tests</groupId>
<artifactId>tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/tests</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Examples.java</include>
<include>**/*Properties.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.1</version>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<version>1.5.6</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
</project>
After I'd searched the net and similar StackOverflow questions and tried to apply the proposed sollutions I didn't come up with an idea how to fix this error, which gives me pom.xml:
Multiple annotations found at this line:
- Missing artifact jakarta.json:jakarta.json-
api:jar:2.0.0-RC3
- Missing artifact org.glassfish.hk2:hk2-
locator:jar:3.0.0-M2
- Missing artifact org.glassfish:jakarta.json:jar:2.0.0-
RC3
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 //error appears here
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gson</groupId>
<artifactId>advanced-jaxrs-01</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>advanced-jaxrs-01 Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-
media-moxy -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>3.0.0-M6</version>
</dependency>
<!--
https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri -
->
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>3.0.0-M6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>advanced-jaxrs-01</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-
bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
I've had a look at .m2/repository and I've noticed, that there are files maven can't find. What should I do? What's the matter?
If there are files that maven can't find, you can always try to install the JAR file and going into
Project folder properties --> Java Build Path --> Add external JARs (Click on Modulepath if you cant immediately press Add External JARs)
I am learning Selenium and I would like to try add the maven-compiler-plugin to pom.xml and reimport maven settings. So I found this example to do it http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html and tried to add the code to the pom.xml. But the vrsion from the example 3.8.1 is red like on the screenshot. What it means? It is a copy from example.
Here is the whole 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>camaj.vladimir</groupId>
<artifactId>selenium-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>com.google.code.tempus-fugit</groupId>
<artifactId>tempus-fugit</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
In my case, I have changed the tags from plugin to dependency like it is in the Maven Repository.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
In my case the groupId for the plugin was missing:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
...
In my case, Spring Boot code works fine without changing anything, however, it gives the same error when I tried to commit in Git.
To solve this, I add the version info as follows and it worked.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
...
I've faced this issue with my old project (which was 100% working on my old ItelliJ IDEA) and newly installed ItelliJ IDEA:
in the pom.xml I had this:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
And IDEA throwed an error maven-compiler-plugin not found. I've added
<groupId>org.apache.maven.plugins</groupId>
and IDEA found the plugin, and after that I was free to remove org.apache.maven.plugins without breaking IDEA
I got this error with IntelliJ. tried many ways, the below worked for me:
Close your IDE.
Delete "*.iml" and ".idea" -directories(present in the root folder of project)
Run "mvn clean install" from the command-line
Re-import your project into IDEA
In IntelliJ you can right click on 3.8.1 scroll down to Maven and select "Reimport". This solved the issue for me.
In my case, invalidating cache and restarting solved the issue.
Add the Following code in your pom the issue will resolve
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<forkCount>1</forkCount>
<useFile>false</useFile>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<forkMode>once</forkMode>
<suiteXmlFiles>
<suiteXmlFile>testing.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Make sure you are reimporting your dependency after adding plugins
I went to
.m2\repository\org\apache\maven\plugins\maven-compiler-plugin
and removed older version. It worked
You need to update your project so that the dependencies are updated from Maven side.
To update:
Change the file structure to project view.
Right click on project name -> Maven -> Reload project
And it will download all the necessary dependencies.
One reason could be due to proxy setup on your system in Maven settings.
You can remove/backup the previous maven settings.xml file and this should work.
mv ~/.m2/settings.xml ~/.m2/settings.xml.bak
I use maven-android-plugin, and I get duplicate dependency.
I don't know which dependency should be exclude.
My pom.xml is:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>gs-maven-android</artifactId>
<version>0.1.0</version>
<packaging>apk</packaging>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.14</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.9.0-rc.1</version>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I get below error when I use mvn package:
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/impl/NoOpLog;
I search this information, it seems that there are duplicate library. Now, I think:
Maven should deal with this problem, right?
I find the command causing error below, I do not find duplicate library.
/bin/sh -c cd /Users/diplab/Documents/workspace/engineonandroid &&
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
-Xmx1024M -jar /opt/Android/android-sdk-macosx/build-tools/19.1.0/lib/dx.jar --dex
--output=/Users/diplab/Documents/workspace/engineonandroid/target/classes.dex
/Users/diplab/.m2/repository/org/springframework/spring-asm/3.1.2.RELEASE/spring-asm-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar
/Users/diplab/.m2/repository/org/springframework/spring-core/3.1.2.RELEASE/spring-core-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.9/jackson-core-asl-1.9.9.jar
/Users/diplab/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar
/Users/diplab/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
/Users/diplab/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
/Users/diplab/Documents/workspace/engineonandroid/target/classes
/Users/diplab/.m2/repository/org/activiti/activiti-bpmn-converter/5.14/activiti-bpmn-converter-5.14.jar
/Users/diplab/.m2/repository/org/mybatis/mybatis/3.2.2/mybatis-3.2.2.jar
/Users/diplab/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
/Users/diplab/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
/Users/diplab/.m2/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/org/activiti/activiti-engine/5.14/activiti-engine-5.14.jar
/Users/diplab/.m2/repository/org/apache/commons/commons-email/1.2/commons-email-1.2.jar
/Users/diplab/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.2/jcl-over-slf4j-1.7.2.jar
/Users/diplab/.m2/repository/org/activiti/activiti-bpmn-model/5.14/activiti-bpmn-model-5.14.jar
What should I do?