Wednesday, 30. September 2020 11:45 - 12:15 (30 min)
Most sessions on developer testing today talk about the tools and libraries we can use to write our unit and integration tests. The "how" question has been answered in most popular framework nowadays, as is the case in AEM. With JUnit, Mockito and AEM Mocks being already a quite mature combination of solutions for testing our backend logic.
However, we developers rarely find any time to think about how our testing strategy should look like. Important questions like: "What should we test/cover and what not?" or "When should we go for unit vs integration test?" still remain a mystery for some developers in the industry.
In this presentation we will try to shed some light on questions like these for AEM customized solutions in general. Same as with writing your code, when writing your test cases, clarity is king. We will discuss and demonstrate some best practices for making our tests cleaner, readable, understandable and thus maintainable.
- Test your business logic, not the framework you are using
- Only test the things you expose, your public API, nothing else
- Invest the needed time to describe what you are testing
- Create mocks for services based on their interfaces
- Separate mocked classes from test classes to make tests cleaner
- Never test or mock private methods and utilities
- Secure time for writing tests in advance, it needs to be planned
- You are in charge of the code quality and code coverage