I am trying to separate unit and integration tests through maven command.
pom.xml
....
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Fast*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is my integration test
@RunWith(SpringRunner.class)
@SpringBootTest(classes = StudentApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class StudentControllerIT {
...
and this is unit test
@RunWith(SpringRunner.class)
@WebMvcTest(value = StudentController.class, secure = false)
public class StudentFastControllerTest {
....
Now when I try to run command mvn test
then only StudentFastControllerTest
tests are executed but when I run command mvn integration-test
or mvn verify
both test classes are executed instead of only StudentControllerIT
.