-
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.
JUnit: throwing an AssumptionViolationException will not lead to a fa…
…iled scenario anymore. Instead, the scenario will be ignored and will not appear in the report at all. Fixes #185
- Loading branch information
Jan Schäfer
committed
Feb 6, 2016
1 parent
397fccd
commit cfff549
Showing
4 changed files
with
43 additions
and
0 deletions.
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/AssumptionTest.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.assertj.core.api.Assertions; | ||
import org.junit.AssumptionViolatedException; | ||
import org.junit.Test; | ||
|
||
import com.tngtech.jgiven.annotation.Description; | ||
import com.tngtech.jgiven.junit.test.GivenTestStep; | ||
import com.tngtech.jgiven.junit.test.ThenTestStep; | ||
import com.tngtech.jgiven.junit.test.WhenTestStep; | ||
import com.tngtech.jgiven.report.model.ScenarioCaseModel; | ||
import com.tngtech.jgiven.report.model.StepStatus; | ||
|
||
@Description( "Scenarios can have sections" ) | ||
public class AssumptionTest extends ScenarioTest<GivenTestStep, WhenTestStep, ThenTestStep> { | ||
|
||
@Test | ||
public void JUnit_assumption_exceptions_should_be_treated_correctly() throws Throwable { | ||
try { | ||
when().some_assumption_fails(); | ||
Assertions.fail( "AssumptionViolationException should have been thrown" ); | ||
} catch( AssumptionViolatedException e ) {} | ||
|
||
getScenario().finished(); | ||
|
||
ScenarioCaseModel aCase = getScenario().getModel().getLastScenarioModel().getCase( 0 ); | ||
assertThat( aCase.getStep( 0 ).getStatus() ).isEqualTo( StepStatus.PASSED ); | ||
} | ||
|
||
} |
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