Answer 10: Testing Exceptional Conditions

Is this behavior properly documented? If not, it's a bug.

    public void testAddNull() {
        Fraction a = new Fraction(5, 3);
        try {
            Fraction f = null;
            a.add(null);
            fail("added null");
        }
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());
        }
    }

Previous | Next | Top | Cafe con Leche

Copyright 2005-2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified October 4, 2006