Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.9
-
Fix Version/s: 0.9
-
Component/s: None
-
Labels:None
-
Environment:HideLinux misha-d630 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 19:31:57 UTC 2010 x86_64 GNU/Linux
java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
ShowLinux misha-d630 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 19:31:57 UTC 2010 x86_64 GNU/Linux java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
Description
Perhaps this is expected but it certainly had me stumped for a few
hours. Apparently errors in @After statements take precedence over those
in @Test statements, thus if both:
a) a @Test fails
and
b) and @After fails
You will only get the @After failure in the report (e.g., if there is an
assertion in the @After statement you will never see the exception)
Here is sample code:
import org.junit.After
import org.junit.Before
import org.junit.Test
import static org.junit.Assert.*
class MyTestTest {
@Before public void beforeTests() {
println "Before"
}
@Test public void testLogin() { println "Before asdf" asdf println "After asdf" }
@After public void logoutOfMyTest() {
println "After"
blah
}
}
You will see the blah error but not the asdf error.
This looks quite simple, but when there is an assert somewhere in a call
in the After that goes awry, can be quite devastating/confusing.
Thank you!
I don't think it's to be expected. Both IDEA and Maven 2 (command line + report) show both errors.