From part 1, I have placed
the problem of term component test
test type: it looks like that the team try addressing source file integration as a
unit of test. However, as I mentioned before, line coverage and branch coverage metrics
surely cover such concern. So I go further to have a personal flavor for its definition.
To address this, I set up my standing point and direction as following:
- Standing point is the entry point of the application
- Direction is looking outward application
Then I simply answer this question to identify component for the application:
What else does it require running, so as the application can fulfill all of its functionalities?
Again, here is the application mock from previous post:
Here component list from sample application:
- Database is a software component
- Kafka broker is another software component
- External API (either Rest API or GraphQL)
In another word, I just slim down the application by not concerning source files but addressing what is mandatory for the application except the application itself.
The whole source tree from this approach is now a single component of the application. By this lens, I don’t concern any set of source files, but I see the whole source tree is just only one component of the application. As a result of this, I would say that I should cover following scopes:
- any interaction between app and database (read queries, persist data, transaction)
- any interaction between app and Kafka (consuming and publishing)
- any interaction between app and external Rest API (consuming API)
As you may notice, each of interaction pair above may produce two set of tests:
- happy path test where the operation completes successfully
- unhappy path test where there is error for one component to complete request operation.
Conclusion
So that’s it. This is my definition if I must have for unit test targeting component test
. I think I have placed the
term well enough as a guidance. Now any software engineer want to have “type” for their unit test, I think by reading
what is the scope of current source file, they definitely know how to write tests to cover “king and queen” metrics:
line coverage and branch coverage.