Answer 9: Testing Exceptional Conditions

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

    public void testAddNull() {
        Fraction a = Fraction.getFraction(5, 3);
        try {
            Fraction f = null;
            a.add(null);
            fail("added null");
        }
        catch (IllegalArgumentException success) {
            // This really is a bug. This should be a NullPointerException
            assertNotNull(success.getMessage());
        }
    }

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

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