TLDR
Configured test tooling for the backend Java application. Wrote initial unit tests to raise code coverage from 0% to 44%.
Main work
- Added Maven configurations for generating HTML test success/failure reports and overall code coverage metrics.
- surefire reports maven plugin for test success / failures
- jacoco maven plugin for generating code coverage reports
- Created unit tests for
IActionandCatanGraphclasses.
Challenges
- Mavens stages / goals / concepts are powerful but complicated. For the most part testing tools have been bootstrapped for me by someone else.
- Deciding first testing structure is important for “setting the tone” on the rest of the project.
- I went with
given, when, thenpatterns.
- I went with
- Identifying the lowest hanging fruit that will up test coverage and actually increase confidence that I will catch breaking changes in the future.
Learnings
@Datalombok notation is nice, but generates many methods liketoHash()andisEqual(). This is not necessarily needed for some classes, and increases the amount of code that requires test coverage.- Two solutions: (1) use
@Getterand@Setterif you don’t truly need hash functions or overrided equality checks. (2) setup test tooling to ignore the boilerplate methods generated by Lombok. - I went with the former for expediency, but the later is probably preferred.
- Two solutions: (1) use