-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #601 from skazzyy/master
Fix for issue #499 Assumes in tests run by Theories
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 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
47 changes: 47 additions & 0 deletions
47
src/test/java/org/junit/tests/experimental/theories/AssumingInTheoriesTest.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,47 @@ | ||
package org.junit.tests.experimental.theories; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Assume; | ||
import org.junit.Test; | ||
import org.junit.experimental.theories.DataPoint; | ||
import org.junit.experimental.theories.Theories; | ||
import org.junit.experimental.theories.Theory; | ||
import org.junit.runner.JUnitCore; | ||
import org.junit.runner.Request; | ||
import org.junit.runner.Result; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runner.Runner; | ||
import org.junit.runners.model.InitializationError; | ||
|
||
@RunWith(Theories.class) | ||
public class AssumingInTheoriesTest { | ||
|
||
@Test | ||
public void noTheoryAnnotationMeansAssumeShouldIgnore() { | ||
Assume.assumeTrue(false); | ||
} | ||
|
||
@Test | ||
public void theoryMeansOnlyAssumeShouldFail() throws InitializationError { | ||
JUnitCore junitRunner = new JUnitCore(); | ||
Runner theoryRunner = new Theories(TheoryWithNoUnassumedParameters.class); | ||
Request request = Request.runner(theoryRunner); | ||
Result result = junitRunner.run(request); | ||
Assert.assertEquals(1, result.getFailureCount()); | ||
} | ||
|
||
/** | ||
* Simple class that SHOULD fail because no parameters are met. | ||
*/ | ||
public static class TheoryWithNoUnassumedParameters { | ||
|
||
@DataPoint | ||
public final static boolean FALSE = false; | ||
|
||
@Theory | ||
public void theoryWithNoUnassumedParameters(boolean value) { | ||
Assume.assumeTrue(value); | ||
} | ||
} | ||
|
||
} |