1

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?

asked Jul 10, 2021 at 22:09

1 Answer 1

2

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

answered Jul 11, 2021 at 1:34
3
  • 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)? Commented 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. Commented 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. Commented Jul 11, 2021 at 14:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.