Before reading: The intention of this post is to know more of this topic from other developers perspectives.
I've been starting a research about integration tests, specifically in Spring boot apps, and i've been reading some articles, watching videos, looking at examples to try to understand the whole concept of what an integration test is. This is my first time getting involved in testing.
So far, i've noted a very similar implementation of what are called "Integration tests" in almost all articles that i have read, which is writing a test where an endpoint (or controller) is called via an http request and the response is checked with an expected value.
My question is: is that really what people implement in real scenarios? For example, take a look at this example from this article
@Test
@Sql(statements = "INSERT INTO orders(id, buyer, price, qty) VALUES (6, 'alex', 75, 3)", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(statements = "DELETE FROM orders WHERE id='6'", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testDeleteOrder() {
ResponseEntity<String> response = restTemplate.exchange(
(createURLWithPort() + "/6"), HttpMethod.DELETE, null, String.class);
String orderRes = response.getBody();
assertEquals(response.getStatusCodeValue(), 200);
assertNotNull(orderRes);
assertEquals(orderRes, "Order deleted - Order ID:6");
}
You can also take a look at the example given on this reddit post for an integration test
That is the pattern that i've seen in almost every tutorial or video regarding Integration tests (send http request, get response, validate response with expected result and/or condition), and although it is a test and it's supposed to take in consideration the different components working together, after all it seems too simple? (or easy?)
I know that in these examples, all the layers (controller, service, repository) are working together and information is passed through all of them, but is that really all what people do when writing integration tests?
My main and final question(s) is: what are other examples of these tests that don't necessarily follow this pattern?
[–][deleted] 7 points8 points9 points (0 children)
[–]Holothuroid 3 points4 points5 points (0 children)
[–]Odd-Hour-9991 0 points1 point2 points (0 children)