Search⌘ K
AI Features

Last Tests

Explore techniques to address failing unit tests in Java using JUnit, including adding conditionals, deleting redundant tests, and improving design through refactoring. Understand how to maintain reliable and clean tests by managing special cases like 'dontCare' criteria and structuring tests for clarity.

We'll cover the following...

There is a special case where matches() returns true when the criterion is marked as dontCare:

Java
//...
@Test
public void matchesWhenCriterionIsDontCare() {
profile.add(answerDoesNotReimburseTuition);
Criterion criterion =
new Criterion(answerReimbursesTuition, Weight.DontCare);
assertTrue(profile.matches(criterion));
}

Making the test pass requires the addition of a ...