question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssumeTrue and AssumeFalse do not work as documented.

See original GitHub issue

public 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:closed
  • Created 10 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bugpartycommented, Jun 13, 2016

I have the same problem on Intellij IDEA

0reactions
marcphilippcommented, Dec 8, 2014

Thanks for verifying!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found