mercredi 17 janvier 2018

How do I do integration testing and end to end testing?

I recently started TDD approach in our project and we have done good unit testing so far but we are stuck with the question of integration and end to end tests. Say I have three objects whose constructors are as following

constructor(kafka, sql, filesystem); // mock all the three
constructor(mongo, webservice, kafka); // mock all the three
constructor(googlemaps, sql); // mock all the two

I have 6 external components to be integrated into my application. I can do unit testing for the three objects by mocking all their dependencies in constructor injection and I can also do end to end testing by having real time set up for all the 6 external components.

My question is how do I deal with integration testing? does Integration testing deal with object testing? I believe unit testing deals with object testing, so integration must deal with external component testing. If I want to write integrate testing, How do I go with?

constructor(kafka, sql, filesystem); mock sql, filesystem but kafka is real
constructor(mongo, webservice, kafka); mock monog, service but kafka is real
constructor(googlemaps, sql); // mock all the two   

Write tests by making kafka real setup and others as mocked. If I go this way I end up with repetitive code similar to Unit test but instead of mocking, I end up with real environment but the tests will be same?

Can I have unit testing and end to end tests only? because end to end test does integration test for all objects. If end to end test does everything why does we still do integration tests? What are some best practices for doing integration tests. Any help is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire