Issue
I am not able to run my unit test using maven. I tried using mvn clean install and mvn test to run the test, but is not providing the expected result.
I have included the following dependencies :
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams-test-utils</artifactId>
<scope>test</scope>
</dependency>
<build>
<plugins>
<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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<!--include manifest in repository jar-->
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The test class contains the following nomenclature and annotation :
@ExtendWith(SpringExtension.class)
@SpringBootTest(
webEnvironment = WebEnvironment.NONE,
classes = {TruckIdLookupService.class, TimescaleConfiguration.class})
public class TestClassName {
The method name as following annotation and name:
@Test
void testMethodName() throws Exception {
I am able to get expected result in Intellij but maven is not running the tests.
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ truckmsg-processor ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Solution
Changing the junit Jupiter dependency helped :
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
Answered By - Ankita