views:

439

answers:

2

I've been coding tests in Junit4 with Spring, and I got this funny behavior:

If my tests are passing like this, everything is fine:

@Test
public void truthTest(){

 assertTrue(true); //Ok

}

But, if my test fails:

@Test
public void truthTest(){

 assertTrue(false); //ERROR

}

Then instead of a test failure I receive an ugly and cryptic stack trace, This is it:

http://pastie.org/429912

Sorry for this ugly dump, but its the only data I've got to explain the problem (I "pastied" it for readability)

I'm really puzzled, has anyone encountered this kind of problem before? Thanks in advance!

A: 

What if you imported AssumptionViolatedException into your test class?

It looks like it can't find the class to throw the appropriate exception.

Eric Wendelin
I've imported org.junit.internals.AssumptionViolatedException but it doesnt work either
Pablo Fernandez
+5  A: 

http://jira.springframework.org/browse/SPR-5145

It is an known issue with spring-test 2.5.x. It is incompatible with JUnit 4.5. Use 4.0-4.4.

Or you can try the patch in the issue tracker.

lsiu
On a bit of a side note: (as of now), the solution is "If you are using 4.0-4.4, try 4.5. If you are using 4.5, try 4.0-4.4". I just had the same issue and I solved it by upgrading to 4.5.
Christopher W. Allen-Poole