AssumeTrue and AssumeFalse do not work as documented.
See original GitHub issuepublic class AssumptionTests {
@Test
public void assumeTruePassTest1()
{
// If called with an expression evaluating to false, the test will halt and be ignored.
Assume.assumeTrue(true); // should pass
// actual is test is passed.
}
@Test
public void assumeTruePassTest2()
{
// If called with an expression evaluating to false, the test will halt and be ignored.
Assume.assumeTrue(true); // should pass
Assert.fail(); // should fail test
// actual is test ignored.
}
@Test // (expected = AssumptionViolatedException)
public void assumeTrueFailTest1()
{
// If called with an expression evaluating to false, the test will halt and be ignored.
Assume.assumeTrue(false); // should fail with ignored
// actual result is pass.
}
@Test // (expected = AssumptionViolatedException)
public void assumeTrueFailTest2()
{
// If called with an expression evaluating to false, the test will halt and be ignored.
Assume.assumeTrue(false); // should fail with ignored.
Assert.fail(); // should not be reached.
// actual result is pass.
}
}
The AssumptionViolatedException appears to be correctly thrown, but is handled incorrectly. Perhaps org.junit.internal.AssumptionViolatedException should be moved to non-internal package and require explicit handling.
This is not
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Assume (JUnit API)
A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean...
Read more >Logging failed assumptions in JUnit - java - Stack Overflow
The documentation says that failed assumptions aren't logged because there may be lots of unit tests that are not necessary due to varying ......
Read more >Use org.junit.Assume.assumeTrue in junit with Examples
Learn how to use assumeTrue method in org.junit.Assume for your next JUnit project with LambdaTest Automation Testing Advisor.
Read more >Java static code analysis: JUnit4 @Ignored and JUnit5 ...
For Junit5, this rule targets the @Disabled annotation. Cases where assumeTrue(false) or assumeFalse(true) are used to skip tests are targeted as well.
Read more >assumeTrue() - Java Unit Testing with JUnit 5 - Educative.io
This lesson demonstrates how to use assumeTrue and assumeFalse methods in JUnit 5 to make ... if the assumption is true then test...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same problem on Intellij IDEA
Thanks for verifying!