Testing exceptional conditions

    public void testParseComplexThrowsNumberFormatException() {
         
        try {
            Complex z = Complex.parseComplex("Foo");
            fail("Parsed Foo as complex number");
        }
        catch (NumberFormatException success) {
            assertTrue(success.getMessage().indexOf("Foo") >= 0);
        }
        
    }

Previous | Next | Top | Cafe au Lait

Copyright 2005 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 5, 2005