Supporting Multiple Answers: A Small Design Detour

A profile can contain many answers, so the next test tackles that scenario:

public​ ​void​ matchesWhenContainsMultipleAnswers() {
Criterion criterion =
new​ Criterion(answerThereIsRelocation, Weight.Important);
boolean​ result = profile.matches(criterion);

Having multiple Answers in the Profile requires a way to store and distinguish them. We choose to store the Answers in a Map where the key is the question text and the value is the associated Answer. (It’d probably be better to use an Answer ID as the key, ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.