'Spring boot test files execution ordering

I have a project with several hundred test files some of the test files use DataJpaTest annotation, some are MockMvc based controller tests and some uses mocked objects without database dependency, Based on test execution order I see context needs to be re-initialized for different flavors of test files, Is there a way to control execution of test files order so that context reload can be avoided? Say all mock tests first followed by controller tests and then DataJpaTest? Right now test case execution taking about 30 minutes looking for way to improve the speed up test execution.



Solution 1:[1]

JUnit Jupiter provides options to control Test Execution Order.

However, you should look into your test setup and verify if your tests create too many Application Contexts. Spring Test framework can cache Application Contexts and reuse them among different test suites. See Spring Test documentation for more info.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jumb0jet