### Question:
QualityService { int getQualityPercentage(ScenarioCountDTO counts) { if (counts.getTotal() <= 0) { return 100; } return 100 * counts.getPassed() / counts.getTotal(); }  void computeQuality(Execution execution);  }### Answer:
@Test public void getQualityPercentage_should_return_100_when_no_scenario() { ScenarioCountDTO counts = new ScenarioCountDTO().withTotal(0); final int percentage = cut.getQualityPercentage(counts); assertThat(percentage).isEqualTo(100); }
@Test public void getQualityPercentage_should_return_50_when_half_scenarios_succeed() { ScenarioCountDTO counts = new ScenarioCountDTO().withPassed(1).withTotal(2); final int percentage = cut.getQualityPercentage(counts); assertThat(percentage).isEqualTo(50); }
@Test public void getQualityPercentage_should_truncate_instead_of_round_to_not_return_100_when_not_fully_passed() { ScenarioCountDTO counts = new ScenarioCountDTO().withPassed(199).withTotal(200); final int percentage = cut.getQualityPercentage(counts); assertThat(percentage).isEqualTo(99); }