Skip to content

exception type not shown in the report #154

@adrian-herscu

Description

@adrian-herscu

Given JGiven version 0.9.3
And a test failing with an exception or on timeout
When the test is executed
Then the report does not contain the exception type (that is the failure reason)

Example:

@Test(timeOut = 1000)
public void shouldFailOnTimeout() throws Exception {
    when().$("sleeping too much", //$NON-NLS-1$
            new StepFunction<When<Any, ?>>() {
                @Override
                public void apply(final When<Any, ?> stage)
                        throws Exception {
                    Thread.sleep(2000);
                }
            });
}

Is reported as follows:

Generic Should fail on timeout  FAILED (22ms)
FAILED:
com.tngtech.jgiven.base.ScenarioTestBase.when(ScenarioTestBase.java:30)
com.ebay.jgiven.commons.scenarios.GenericTest.shouldFailOnTimeout(GenericTest.java:77)
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:196)
com.ebay.qa.jgiven.commons.utils.UnitilsScenarioTest.run(UnitilsScenarioTest.java:107)
org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:208)
org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:56)
org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
java.util.concurrent.FutureTask.run(FutureTask.java:262)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)

Note the "FAILED:" line. It does not contain the reason.

And another example:

@Test
public void shouldFailWithUnexpectedRuntimeException() throws Exception {
    then().$("should throw a runtime exception", //$NON-NLS-1$
            new StepFunction<Then<Any, ?>>() {
                @Override
                public void apply(final Then<Any, ?> stage)
                        throws Exception {
                    throw new RuntimeException();
                }
            });
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions