Answer 8 Improved: Data Driven Test

This variant now runs all tests even if one test fails:

    public void testIntegrationGetProperNumerator() {
        
        int failures = 0;
        StringBuffer failureMessage = new StringBuffer();
        for (int i = 0; i < data.length; i++) {
          int[] row = data[i];
          Fraction f = Fraction.getFraction(row[0], row[1]);
          try {
              assertEquals(row[2], f.getProperNumerator());
          }
          catch (AssertionFailedError err) {
              failures++;
              failureMessage.append(err.getMessage() + "\n");
          }
        }
        
        if (failures > 0) fail(failureMessage.toString());
        
    }

Previous | Next | Top | Cafe con Leche | Cafe au Lait

Copyright 2005 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 11, 2005