Class ExceptionTestCase

  • All Implemented Interfaces:
    Test

    public class ExceptionTestCase
    extends TestCase
    A TestCase that expects an Exception of class fExpected to be thrown. The other way to check that an expected exception is thrown is:
     try {
       shouldThrow();
     }
     catch (SpecialException e) {
       return;
     }
     fail("Expected SpecialException");
     
    To use ExceptionTestCase, create a TestCase like:
     new ExceptionTestCase("testShouldThrow", SpecialException.class);
     
    • Constructor Detail

      • ExceptionTestCase

        public ExceptionTestCase​(java.lang.String name,
                                 java.lang.Class exception)
    • Method Detail

      • runTest

        protected void runTest()
                        throws java.lang.Throwable
        Execute the test method expecting that an Exception of class fExpected or one of its subclasses will be thrown
        Overrides:
        runTest in class TestCase
        Throws:
        java.lang.Throwable - if any exception is thrown