How to run multiple tests with Spring Boot
spring-boot
Solution
What I have done is as follows: In the main class
@RunWith(Suite.class)
@Suite.SuiteClasses({
PostServiceTest.class,
UserServiceTest.class
})
public class DataApplicationTests {
@Test
public void contextLoads() {
}
}
In the PostServiceTest I have
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class PostServiceTest {
@Autowired
IPostService postService;
@Before
public void initiate() {
System.out.println("Initiating the before steps");
}
@Test
public void testFindPosts() {
List<Post> posts= postService.findPosts();
Assert.assertNotNull("failure - expected Not Null", posts);
}
}
The second class, UserServiceTest has similar structure.
When I run the DataApplicationTests, it runs both the classes.
Problem
With Spring Boot 1.5, how could I run multiple tests which are in different classes? E.g. ``` I have `Service1` tests in `Service1test.java`; I have `Service2` tests in `Service2test.java`; ``` I shall need to run both in one go.