Search in sources :

Example 1 with CustomException

use of com.oracle.tck.lib.autd2.unittests.CustomException in project jtharness by openjdk.

the class TestCaseThrowsException method unexpectedRuntimeException.

@Test
public void unexpectedRuntimeException() {
    PrintWriter log = TU.createMockedPrintWriter();
    PrintWriter ref = TU.createMockedPrintWriter();
    BaseTestGroup baseTestGroup = new BaseTestGroup() {

        Values setup() {
            return DataFactory.createColumn(115);
        }

        @TestCase
        @TestData("setup")
        public void theTest(int i) {
            throw new CustomException(Integer.toString(i));
        }
    };
    com.oracle.tck.lib.autd2.TestResult status = TU.runTestGroup(baseTestGroup, log, ref);
    Assert.assertTrue(!status.isOK());
    Assert.assertEquals("Failed. test cases: 1; all failed", status.toString());
    InOrder inOrder = inOrder(log, ref);
    inOrder.verify(log).println("Testcase \"theTest(0)\" has thrown an unexpected exception com.oracle.tck.lib.autd2.unittests.CustomException: 115");
    inOrder.verify(log).println(CustomException.STACKTRACE_LINE);
    inOrder.verify(log).println("Testcase \"theTest(0)\" failed with arguments [115]");
    inOrder.verify(log).println("theTest: Failed. Testcase \"theTest(0)\" has thrown an unexpected exception com.oracle.tck.lib.autd2.unittests.CustomException: 115");
    inOrder.verify(log).flush();
    inOrder.verify(ref).flush();
    verifyNoMoreInteractions(log, ref);
}
Also used : InOrder(org.mockito.InOrder) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) CustomException(com.oracle.tck.lib.autd2.unittests.CustomException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)1 CustomException (com.oracle.tck.lib.autd2.unittests.CustomException)1 PrintWriter (java.io.PrintWriter)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1