lundi 13 mai 2019

What are integration tests containing and how to set them up

I’m currently learning about unit tests and integration testing and as I understood it, unit tests are used to test the logic of a specific class and integration tests are used to check the cooperation of multiple classes and libraries.

But is it only used to test multiple classes and if they work together as expected, or is it also valid to access databases in an integration test? If so, what if the connection can‘t be established because of a server sided error, wouldn’t the tests fail, although the code itself would work as expected? How do I know what‘s valid to use in this kind of tests?

Second thing I don‘t understand is how they are set up. Unit tests seem to me have a quite common form, like:

public class  classTest {

    @BeforeEach
    public void setUp(){
    }

    @Test
    public void testCase(){
    }
}

But how are integration tests written? Is it commonly done the same way, just including more classes and external factors or is there another way that is used for that?

Aucun commentaire:

Enregistrer un commentaire