C[O]RRECT: [O]rdering

The order of data, or the position of one piece of data within a larger collection, represents a CORRECTness criterion where it’s easy for code to go wrong.

Let’s look at a need for ordering in the iloveyouboss application. One of the application’s core features is to score a list of companies based on how well they match criteria. Naturally, we always want to see the best match first, followed by the losers, biggest loser last.

The answersResultsInScoredOrder test represents the ordering need:

iloveyouboss/15/test/iloveyouboss/ProfilePoolTest.java
 
@Test
 
public​ ​void​ answersResultsInScoredOrder() {
 
smeltInc.add(​new​ Answer(doTheyReimburseTuition, Bool.FALSE));
 
pool.add(smeltInc);
 
langrsoft.add(​new​ Answer(doTheyReimburseTuition, ...

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.