Testing Databases
We first saw the StatCompiler code in [F]IRST: [F]ast!. We were able to refactor this class so that most of its code doesn’t directly interact with a QuestionController instance, which in turn let us write fast tests for the bulk of its logic. We were left with one method, questionText(), that interacts with a controller object, and we’d now like to test that method:
iloveyouboss/16-branch-persistence-redesign/src/iloveyouboss/domain/StatCompiler.java | |
| public Map<Integer,String> questionText(List<BooleanAnswer> answers) { |
| Map<Integer,String> questions = new HashMap<>(); |
| answers.stream().forEach(answer -> { |
| if (!questions.containsKey(answer.getQuestionId())) |
| questions.put(answer.getQuestionId(), ... |
Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.