[Right]-BICEP: Are the Results Right?
Explore the Right-BICEP method to write unit tests that verify correct results in Java applications. Learn to create happy path tests that validate expected outcomes, understand their importance, and how tests document code behavior for future refinement.
We'll cover the following...
We'll cover the following...
Our tests should first validate that the code produces the expected results. The arithmetic-mean test below demonstrates that the ScoreCollection class produces the correct mean of 6 given the numbers 5 and 7.
@Test
public void answersArithmeticMeanOfTwoNumbers() {
ScoreCollection collection = new ScoreCollection();
collection.add(() -> 5);
collection.add(() -> 7);
int actualResult = ...