[GRADLE-1879] org.junit.Assume isn't handled correctly sometimes Created: 30/Oct/11 Updated: 04/Jan/13 Resolved: 30/Oct/11 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-3 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Andrew Spina | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 0 |
Description |
When I run gradle build on a file like this: import org.junit.Assume; public class MyAssumptionJUnitTest extends TestCase { public void testAssumeClause() { Assume.assumeTrue( false ); }} The build fails unexpectedly. There is a stacktrace as follows in the test report: org.junit.Assume$AssumptionViolatedException: got: <false>, expected: is <true> ======= Joern Huxhorn replied to my query on the user list with the following: The problem below is not caused by Gradle but by a misuse of JUnit. The following code does not fail with Gradle 1.0-m5 and JUnit 4.10: import org.junit.Test; import static org.junit.Assert.fail; public class AssumptionTest { } The problem is caused by "extends TestCase", i.e. using JUnit 3.8 functionality. Beside that, one could probably argue that tests ignored due to unmet assumptions should print something during Gradle build. I like the extreme noiselessness of Gradle, though. Cheers, |
Comments |
Comment by Joern Huxhorn [ 30/Oct/11 ] |
The problem is not caused by Gradle but by a misuse of JUnit. The following code does not fail with Gradle 1.0-m5 and JUnit 4.10: import org.junit.Test; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; public class AssumptionTest { @Test public void foo() { assumeTrue(false); fail("Will not fail.") } } The problem is caused by "extends TestCase", i.e. using JUnit 3.8 functionality. Beside that, one could probably argue that tests ignored due to unmet assumptions should print something during Gradle build. I like the extreme noiselessness of Gradle, though. |
Comment by Joern Huxhorn [ 30/Oct/11 ] |
Whoops, you mentioned that already. |
Comment by Peter Niederwieser [ 30/Oct/11 ] |
Joern is right. Don't mix JUnit 3 (TestCase) with JUnit 4 (Assume). |
Comment by Joern Huxhorn [ 31/Oct/11 ] |
This version of the code import junit.framework.TestCase; import static org.junit.Assume.assumeTrue; public class AssumptionTest extends TestCase { public void testFoo() { assumeTrue(false); fail("Will not fail."); } } fails in IDEA in the same way, i.e. org.junit.internal.AssumptionViolatedException: got: <false>, expected: is <true> at org.junit.Assume.assumeThat(Assume.java:70) at org.junit.Assume.assumeTrue(Assume.java:39) at AssumptionTest.testFoo(AssumptionTest.java:11) |
Comment by Andrew Spina [ 04/Nov/11 ] |
I ran a similar test in Eclipse and found that JUnit 3 tests don't function correctly with Assume. I agree that this issue should not be fixed. |