dimanche 3 juillet 2016

Slow unit testing in spring-boot application

I'm still new to unit testing. I started to read a book about it. But one of the most important thing is that a test hast to be first (Fast,Isolated,Repeatable,Self-validating,Timely).

Okay, now I was ready for a bit of practice. But when I was building unit test in spring boot. I like to keep them separated.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = UnitTestApplication.class, loader = SpringApplicationContextLoader.class)
@WebIntegrationTest("server.port:9000")
public class FirstTestClassTest{

    ...

}


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = UnitTestApplication.class, loader = SpringApplicationContextLoader.class)
@WebIntegrationTest("server.port:9001")
public class SecondTestClassTest{

    ...

}

This gives me the problem that for every test class there is a new instance started of the application.

So let's say I introduce a new feature and want to test for bugs. I use mvn test form the command line. Then all the test are run but i think it will take ages for a real application with a lot of tests.

I there a way that there is only one instance started and keep the test fast but where i can keep the test in separate classes?

Aucun commentaire:

Enregistrer un commentaire