In my project there are many tests marked with @SpringBootTest which I don't regard as unit tests and rather as integration tests. So I would like to run only the unit tests when I execute:
mvn clean install
actually I want to run this command as part of pre-commit git hook but @SpringBootTest makes it longer to finish execution.
Is there a way to exclude the tests marked with @SpringBootTest? May be there is a pattern we can pass to maven that excludes/certain tests. Or may be write a test suite that includes the spring boot tests.
I did google search to achieve the above but don't have much luck.
Is there even a better way?
@Update: Constraint is maven pom file can't be modified.
@Update2: I have a solution that looks promising:
1. Use @Category("IntegrationTests") for @SpringBootTests tests.
2. Create TestSuite with excludeCategory:
@RunWith(CategoryRunner.class)
@ExcludeCategory("IntegrationTests")
public class TestSuite {
}
3. From mvn command line, run only TestSuite.
I am not sure this is the best. Appreciate anyone's better approach.