Weird JUnit problem

Hi gyus.

I'm experiencing something weird with my JUnit (4.5) test (IDEA build #9732, JDK 1.6_10).

I have a test class, extending junit.framework.TestCase, that has 2 test methods. One on these tests fail (assertTrue(false);) and test runner output shows the AssertionFailedError, and "Process finished with exit code -1". Still the left panel (test case tree) shows a green OK mark for the test.

But if I run the whole class (i.e. both test methods) or all of my unit tests, it shows the failing method with an exclamation mark (!) as expected.

Any ideas what could be wrong?

I tried to create a test project for this one (because I can't share the actual project here), but it's working as expected.

3 comments
Comment actions Permalink

Hello Ville,

Seems that this is a known problem with mixed junit4 and junit3: your test
startswith "test" and thus is treated as junit3 test as well as annotated
junit4 test. Right?

Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Hi gyus.

I'm experiencing something weird with my JUnit (4.5) test (IDEA build
#9732, JDK 1.6_10).

I have a test class, extending junit.framework.TestCase, that has 2
test methods. One on these tests fail (assertTrue(false);) and test
runner output shows the AssertionFailedError, and "Process finished
with exit code -1". Still the left panel (test case tree) shows a
green OK mark for the test.

But if I run the whole class (i.e. both test methods) or all of my
unit tests, it shows the failing method with an exclamation mark
as expected.

Any ideas what could be wrong?

I tried to create a test project for this one (because I can't share
the actual project here), but it's working as
expected.

---
Original message URL:
http://www.jetbrains.net/devnet/message/5236554#5236554



0
Comment actions Permalink

You got that one right. test-prefixes as always; I've been mostly using the older JUnits. This is the first project with JUnit4.

If I remove the annotation, the test runs and fails as expected.

If I leave the annotation and rename the method, it doesn't fail at all, even though it end with "assertTrue(false);".

I guess I'll need to dive into JUnit manuals for a deeper understanding of this behaviour.

Thank you for your help!


EDIT: The easiest solution seemed to be to remove the "extend TestCase" and then using static imports for assertXxx methods.

0
Comment actions Permalink

Hello,

I have the same problem, though I'm not using any JUnit 3 naming conventions or anything :/

This internal error occurs during the error:


3534: 3534
java.lang.ArrayIndexOutOfBoundsException: 3534
at com.intellij.execution.junit2.SegmentedInputStream.decode(SegmentedInputStream.java:3)
at com.intellij.execution.junit2.SegmentedInputStream.c(SegmentedInputStream.java:4)
at com.intellij.execution.junit2.SegmentedInputStream.available(SegmentedInputStream.java:30)
at com.intellij.execution.junit.SegmentedInputStreamReader.ready(SegmentedInputStreamReader.java:12)
at com.intellij.execution.process.OSProcessHandler$ReadProcessThread.readNextByte(OSProcessHandler.java:298)
at com.intellij.execution.process.OSProcessHandler$ReadProcessThread.run(OSProcessHandler.java:272)
at com.intellij.openapi.application.impl.ApplicationImpl$5.run(ApplicationImpl.java:8)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:5)



Any ideas?

IDEA 8.1.3, Sun JDK 1.6.0_14 on Windows XP.

Best wishes,
Timo


0

Please sign in to leave a comment.