Maven build scenarios with 'java.lang.ClassNotFoundException' for JUnit 5 after migrating from JUnit 4
I'm reviewing some code and I've searched everywhere and can't find a clear answer. I'm currently migrating a Java project from JUnit 4 to JUnit 5, and I keep running into issues during the Maven build process. After updating the dependencies in my `pom.xml`, I receive a `java.lang.ClassNotFoundException: org.junit.jupiter.api.Test` behavior when I attempt to run my tests. Here are the relevant parts of my `pom.xml`: ```xml <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.8.1</version> <scope>test</scope> </dependency> </dependencies> ``` I've made sure to include the correct version of JUnit 5, as well as the following Maven Surefire plugin configuration: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> </plugin> </plugins> </build> ``` Despite these changes, I still encounter the same `ClassNotFoundException`. I have double-checked that the `maven-surefire-plugin` is the correct version, and I have also tried running `mvn clean` followed by `mvn test` to ensure that there are no old cached classes causing issues. The directory structure of my test classes is as follows: ``` src/test/java/com/example/MyTests.java ``` Inside `MyTests.java`, I have a simple test file: ```java package com.example; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; public class MyTests { @Test public void sampleTest() { assertTrue(true); } } ``` I've also checked that my IDE recognizes the JUnit 5 annotations and imports correctly. However, when building with Maven, it fails to find the JUnit 5 classes. Are there any additional configurations I might be missing that could help resolve this scenario? Any insight would be greatly appreciated! For context: I'm using Java on Ubuntu. What's the best practice here? I'm working with Java in a Docker container on Ubuntu 20.04. I'm coming from a different tech stack and learning Java. Thanks for any help you can provide!