Integration Testing: Devs and QAs
max-arshinov
Posted on March 13, 2023
In the previous articles, we breached the border between integration and unit tests, which introduces a tricky question: how to effectively organize collaboration between devs and QAs. Here is my take on that:
- [DEV] Create Controller Method
-
[DEV] Create
<CONTROLLER_NAME>TestsBase<T>
class -
[DEV] Create
Waf<CONTROLLER_NAME>Tests: ControllerTestsBase<T>
- [DEV] Implement the controller method
-
[DEV] Implement a test in
<CONTROLLER_NAME>TestsBase<T>
- [DEV] Submit a merge request
- [DEV] Merge the request and move Jira issue to "ready for testing"
- [CI/CD] Automatically run WAF tests
-
[QA] Create
Http<CONTROLLER_NAME>Tests: <CONTROLLER_NAME>TestsBase<T>
- [QA] Add missing configs to make the test work in both classes
- [QA] Submit a merge request
- [DEV or/and QA] Merge the request
- [CI/CD] Automatically deploy to the test env
- [CI/CD] Automatically run http tests
- [QA] Do manual testing if needed
- [QA] Resolve Jira issue
As you can see on the BPMN diagram, developers are responsible for the implementation and web-application-factory-based (WAF) tests, while QAs are responsible for testing: both automated using real HTTP calls to real environments. For me, this approach makes more sense than any other one, and that’s why:
- The flow encourages test-driven development. WAF tests are great substitutes for traditional unit tests: they are fast, isolated from external dependencies, and still provide code coverage statistics.
- The flow encourages collaboration, teamwork, and shared code ownership between developers and QAs. This is very in the spirit of DevOps.
- The flow favors the black-box approach over the white-box approach. White-box tests tend to be more fragile because they don’t respect encapsulation.
- All team members do things that they can do best: developers have more experience with coding than QAs. It’s not arrogance or something, they just do coding on a regular basis. QAs in turn, are more concerned about test datasets and scenarios. Most likely, the QA team will be happy to get some help with coding so they can focus on quality.
A note about test data
Preparing and cleaning up the test data might be tedious, error-prone, and time-consuming. Property-based testing technique introduces another approach that focuses on fixing system properties, rather than input/output combinations. Sometimes this approach is worth considering.
Consider the following code:
[Fact]
public async Task LoadMany_GetById_CanFetchAllProductsFromGetAll()
{
var res = await ControllerClient
.SendAsync(c => c.Get())
.LoadMany(
p => ControllerClient.SendAsync(c => c.Get(p.Id)),
p => p.Id);
res.Should().AllSatisfy(x =>
{
x.Value.Details.Should().NotBeNull();
x.Value.Details?.Id.Should().Be(x.Key);
});
}
It checks that every id returned from GET /products
can be provided as a parameter to GET /products/{id}
and that /products/{id}
returns the expected product data. No data setup is needed, albeit two endpoints are checked with great coverage %.
Posted on March 13, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024
November 30, 2024