Answer the question
In order to leave comments, you need to log in
Why are JUnit tests not running in maven?
Essence: There was a small educational project on Java 1.5. Everything in it worked, and the tests were also run. Such is the pom.xml. Which was generated from the quickstart archetype.
<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>ru.intodayer</groupId>
<artifactId>test-arraylist</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test-arraylist</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
<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>
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Answer the question
In order to leave comments, you need to log in
Have you tried google? Tyk!
There is an example pom.xml at the end of the article. It is not difficult to understand it and try to prescribe what you need. If it doesn't help, we'll look into it further.
Just ran into the same problem.
Experimentally, I found out what needs to be added to dependencies and plugins maven-surefire-plugin
.
Example from pom.xml:
.............
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</dependency>
</dependencies>
<build>
<directory>${project.basedir}/target</directory>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
.........
junit-platform-runner
, in this issue, I did not feel in my project.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question