-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add exception type to error message in the report (fixes #154)
- Loading branch information
Jan Schäfer
committed
Dec 19, 2015
1 parent
75b01d4
commit bec4b27
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
jgiven-junit/src/test/java/com/tngtech/jgiven/junit/ExceptionReportingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.tngtech.jgiven.junit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
import com.tngtech.jgiven.Stage; | ||
import com.tngtech.jgiven.StepFunction; | ||
|
||
public class ExceptionReportingTest extends SimpleScenarioTest<ExceptionReportingTest.TestSteps> { | ||
|
||
@Test | ||
public void exception_type_is_contained_in_the_report() throws Throwable { | ||
when().$( "Something", new StepFunction<TestSteps>() { | ||
@Override | ||
public void apply( TestSteps testSteps ) throws Exception { | ||
throw new IllegalStateException( "failing state for testing" ); | ||
} | ||
} ); | ||
|
||
try { | ||
getScenario().finished(); | ||
} catch( IllegalStateException ignore ) {} | ||
|
||
String errorMessage = getScenario().getScenarioModel().getCase( 0 ).getErrorMessage(); | ||
assertThat( errorMessage ).isEqualTo( "java.lang.IllegalStateException: failing state for testing" ); | ||
} | ||
|
||
public static class TestSteps extends Stage<TestSteps> { | ||
|
||
} | ||
} |