TestCase.fName cannot be null when running JUnit

Seeing the following exception five times, once each for my testFoo() methods in this junit testcase

junit.framework.AssertionFailedError: TestCase.fName cannot be null
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:99)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)

Please note that I have dozens of other tests that are working properly.

Here is the basic skeleton of the testcase (confidential code, can't include all of it)

package com.foo.messaging.socket;

import org.junit.Test;
import junit.framework.TestCase;

public class SocketMessagingTest extends TestCase {

public SocketMessagingTest() throws MessagingException, UnknownHostException {
this.runType = RunTypes.both;
receiverHost = InetAddress.getLocalHost().getHostName();
}

enum RunTypes {
sender,
receiver,
both
}

@Test
public synchronized void testReceiverStartup() throws Exception {
// ...
}

@Test
public void testSender() throws Exception {
// ...
}


}

2 comments
Comment actions Permalink

Figured this out..

I had to remove extends TestCase. Don't have any idea why.. but that fixed it.

0
Comment actions Permalink

The TestCase class comes from JUnit 3, whereas the @Test annotation
comes from JUnit 4 - my guess is because your extending TestCase JUnit
treats it as an old style test - which triggers your problems.

On 2008-10-29 18:09:48 +1300, Stephen Boesch <no_reply@jetbrains.com> said:

Figured this out..

I had to remove extends TestCase. Don't have any idea why.. but that fixed it.



0

Please sign in to leave a comment.