-
-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Final test result for JUnit tests failed with exception (#3299)
- Loading branch information
Showing
2 changed files
with
95 additions
and
33 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
68 changes: 68 additions & 0 deletions
68
serenity-model/src/test/java/net/thucydides/model/domain/TestResultTest.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,68 @@ | ||
package net.thucydides.model.domain; | ||
|
||
import org.junit.experimental.runners.Enclosed; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
@RunWith(Enclosed.class) | ||
public class TestResultTest { | ||
|
||
@RunWith(Parameterized.class) | ||
public static class IsMoreSevereTest { | ||
private final TestResult firstStatus; | ||
private final TestResult secondStatus; | ||
private final boolean expectedResult; | ||
|
||
public IsMoreSevereTest(TestResult firstStatus, TestResult secondStatus, boolean expectedResult) { | ||
this.firstStatus = firstStatus; | ||
this.secondStatus = secondStatus; | ||
this.expectedResult = expectedResult; | ||
} | ||
|
||
@Test | ||
public void should_detect_more_severe_results() { | ||
Assertions.assertEquals(firstStatus.isMoreSevereThan(secondStatus), expectedResult); | ||
} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][]{ | ||
{TestResult.FAILURE, TestResult.SUCCESS, true}, | ||
{TestResult.FAILURE, TestResult.FAILURE, false}, | ||
{TestResult.SUCCESS, TestResult.FAILURE, false} | ||
}); | ||
} | ||
} | ||
|
||
@RunWith(Parameterized.class) | ||
public static class IsLessSevereTest { | ||
private final TestResult firstStatus; | ||
private final TestResult secondStatus; | ||
private final boolean expectedResult; | ||
|
||
public IsLessSevereTest(TestResult firstStatus, TestResult secondStatus, boolean expectedResult) { | ||
this.firstStatus = firstStatus; | ||
this.secondStatus = secondStatus; | ||
this.expectedResult = expectedResult; | ||
} | ||
|
||
@Test | ||
public void should_detect_less_severe_results() { | ||
Assertions.assertEquals(firstStatus.isLessSevereThan(secondStatus), expectedResult); | ||
} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][]{ | ||
{TestResult.FAILURE, TestResult.SUCCESS, false}, | ||
{TestResult.FAILURE, TestResult.FAILURE, false}, | ||
{TestResult.SUCCESS, TestResult.FAILURE, true} | ||
}); | ||
} | ||
} | ||
} |