My solution consists of an API for data access and a web application that calls it. I have integration tests set up for the API. However, the actual Web application that calls the API is not a part of these tests. Should integration tests cover the calls from the actual client web application?
1 Answer 1
They could, and if it's possible for you to make them I don't see any reason not to from a reliability standpoint.
But I do believe that those would actually be the so called "end to end tests(E2E)", also fitting Martin Fowler's definition of broad integration tests[1].
You might find somewhat different definitions for integration tests that'd fit mostly in one of these two cases:
narrow integration tests that exercise only that portion of the code in my service that talks to a separate service, that uses test doubles of those services, either in process or remote and thus consist of many narrowly scoped tests, often no larger in scope than a unit test (and usually run with the same test framework that's used for unit tests[1]
or
broad integration tests that require live versions of all services, requiring substantial test environment and network access exercise code paths through all services, not just code responsible for interactions[1]
sources: [1] https://martinfowler.com/bliki/IntegrationTest.html
-
I was wondering if there was any benefit compared to using an integration test to check the API behaves as expected and a unit test to test the client against a mocked API response? I thought E2E tests would need to include user interactions as well (using Selenium or similar)?Peter Dongan– Peter Dongan2021年07月11日 13:30:08 +00:00Commented Jul 11, 2021 at 13:30
-
I think it's valid to write tests to check the behavior of your API, as your said. More precisely, your tests could ensure, for example, that the API is following the "contract", and returning what's expected. So if someone changes the way the API returns stuff it will break the tests and the consumers of your API won't be surprised with missing fields or responses different than the agreed contract.Luiz– Luiz2021年07月11日 14:28:54 +00:00Commented Jul 11, 2021 at 14:28
-
E2E could include things like selenium too I'd say, it depends on what are the ends of your application xD But could also be "just" API call->controller->service->db and see if all worked as expected.Luiz– Luiz2021年07月11日 14:31:09 +00:00Commented Jul 11, 2021 at 14:31
Explore related questions
See similar questions with these tags.