0

I'm trying to update our project from JUnit4 to JUnit5, but I get this error with the imports.

enter image description here

I think the issue is to do with using spring parent. If I remove that from my debug branch it'll work.

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> 

However, there may be a way to keep both?

I tried excluding the JUnit platform-suite-engine from spring test but that didn't work.

 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <exclusions> <exclusion> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-suite-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-suite-engine</artifactId> <version>1.8.2</version> </dependency> 

This is my complete 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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.hmhco</groupId> <artifactId>vcservice</artifactId> <version>1.0.7</version> <name>My Service</name> <description>My Service</description> <properties> <java.version>8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <exclusions> <exclusion> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-suite-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-suite-engine</artifactId> <version>1.8.2</version> </dependency> </dependencies> </project> 

Thank you.

3
  • I guess you’re using the wrong artefact. Should be junit-platform-suite-engine. Commented Apr 12, 2022 at 3:44
  • Thank you. I guess that would have made sense. However, although now I see two options when I type rather than one as before, I'm afraid I still don't see the one I need. I'll update the post with the screenshot. Commented Apr 12, 2022 at 4:15
  • I think the error is to do with the spring parent annotation. It works if I remove that on a debug branch. I'll update the post again. Commented Apr 12, 2022 at 4:53

1 Answer 1

1

Got someone to help me on a forum and adding this fixed the original issue.

<dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-suite-api</artifactId> <version>1.8.2</version> <scope>test</scope> </dependency> 

However, I still can't run the tests as I now get this other issue.

enter image description here

I've tried different combinations of JUnit versions as per here but I can't make it work. I guess though that would be a different issue so I can close this post as resolved.

Sign up to request clarification or add additional context in comments.

1 Comment

My issue was the same as yours, this solved my problem and my tests are still working, but my Suite is not able to recognize the tests (although this might be because of another problem I might have, I'm configuring a Suite for the first time)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.