This might be two different problems, but I suspect both related to tycho, this is why I ask them together.
I have a project using eclipse-test-plugin packaging. As I could not get tycho-surefire-plugin working (see obtaining spring annotation context in tycho-surefire-test ), I resorted to unit tests. They run fine using eclipse, and initially with maven as well. After a tycho version update, the tests started not to run. I guess it has something to do how tycho-maven-plugin changes execution of plugins.
I could get maven-surefire-plugin to run using explicit <execution> tag, but now it says Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider, and does not find the tests. Even when I added junit-jupiter-engine and (perhaps redundantly) junit-jupiter-api as plugin dependencies, as the documentation said.
mvn dependency:tree does not show anything junit 4 related, however the target platform contains org.eclipse.jdt.junit4.runtime.jar.
What happens here and how could I run my unit tests using maven?
Here is everything from the effective pom which I think could be related to the problem:
<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"> <packaging>eclipse-test-plugin</packaging> <dependencyManagement> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.14.0</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.14.0</version> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <version>1.14.0</version> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>5.20.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>3.5.6</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.14.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.14.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <version>1.14.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>6.2.11</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>5.20.0</version> <scope>compile</scope> </dependency> </dependencies> <build> <pluginManagement> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-maven-plugin</artifactId> <version>4.0.12</version> <extensions>true</extensions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.5.4</version> <executions> <execution> <id>plain-unit-tests</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <exclude>**/*PluginTest.class</exclude> <skip>false</skip> <failIfNoTests>true</failIfNoTests> <testClassesDirectory>/home/mag/project/KodeKonveyor/inez-server/inez.parser.tests/target/classes</testClassesDirectory> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.14.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.14.0</version> <scope>compile</scope> </dependency> </dependencies> <configuration> <skip>false</skip> <failIfNoTests>true</failIfNoTests> <testClassesDirectory>/home/mag/project/KodeKonveyor/inez-server/inez.parser.tests/target/classes</testClassesDirectory> </configuration> </plugin> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId> <version>4.0.12</version> <executions> <execution> <id>default-test</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <skip>true</skip> <bundleStartLevel> <bundle> <id>io.github.magwas.inez.parser</id> <level>1</level> <autoStart>true</autoStart> </bundle> </bundleStartLevel> </configuration> </execution> </executions> <configuration> <skip>true</skip> <bundleStartLevel> <bundle> <id>io.github.magwas.inez.parser</id> <level>1</level> <autoStart>true</autoStart> </bundle> </bundleStartLevel> </configuration> </plugin> </plugins> </build> </project>
<testClassesDirectory>/home/mag/project/KodeKonveyor/inez-server/inez.parser.tests/target/classes</testClassesDirectory> </configuration>which does not make sense at all... Where is JUnit 4 ? technically you can execute JUnit 4 based tests via the vintage engine of JUnit Jupiter but it does not make sense because JUnit 4 is out of date ... use JUnit Jupiter (aka JUnit 5 or 6)....