dimanche 19 janvier 2020

Unit testing with @SpringBootTest(classes = Application.class)

Currently a colleague is arguing that

My test written as below:

@SpringBootTest(classes = App.class)
public class ServiceTest {

    private Integer a;
    private String str;


    @Before
    public void prepareTestData() {
       //
    }

    @Test
    public void test_scenario_1() {
        //
    } 
}

is not a unit test for my Service class because I am pulling through all the application using

@SpringBootTest(classes = App.class)

I understand that unit tests should be testing the service code in complete isolation, but I am not having a autowire service depdency injection of any sort in my test code.

My question is what is the @SpringBootTest(classes = App.class) annotation doing behind the scenes is it really bootstraping the complete application before the test code is run?

Is the test above really an integration test?

Aucun commentaire:

Enregistrer un commentaire