oconnor0
oconnor0

Reputation: 3264

JUnit tests in Eclipse Indigo reporting nothing?

I'm trying to get JUnit 4 tests to properly run in Eclipse Indigo SR1, but something is screwy. In the simplest case that I can think of (as below):

package ints;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class IntTest {

    @Before
    public void setUp() throws Exception {
        System.out.println("setUp()");
    }

    @Test
    public void test() {
        System.out.println("assertEquals(1, 1);");
        assertEquals(1, 1);
    }

    @Test
    public void test2() {
        System.out.println("assertEquals(1, 2);");
        assertEquals(1, 2);
    }
}

When I run this in Eclipse (Alt+Shift+X, T), the JUnit view reports "Runs: 0/0, Errors: 0, Failures: 0" while the console displays the below, but I'm not getting anything else. I can throw exceptions from the test methods & they aren't displayed either.

setUp()
assertEquals(1, 1);
setUp()
assertEquals(1, 2);

Any ideas as to what gives?

Upvotes: 2

Views: 1736

Answers (5)

Michał Orliński
Michał Orliński

Reputation: 1408

I had the same problem. JUnit start but not working and not finished and not give any exception. For me worked check firewall iptables command and add run:

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

JUnit need this permission to running - allow internal interface communication.

Upvotes: 0

user1112473
user1112473

Reputation:

I had the same problem with JUnit. I ran update on my good old JDK, but the problem remained, so I completely deleted all JDK-s from my machine and installed the newest jdk 6 and the Eclipse Indigo magically started to work properly.

Maybe the continuously updated jdk 6 is not correctly upgraded...

Upvotes: 1

oconnor0
oconnor0

Reputation: 3264

For some reason uninstalling the 1.7 32-bit JDK solved this problem for me. It didn't seem to be on the path or anything that I could figure out. It feels a little too much like magic, but it worked.

I had 4 JDKs installed (1.6 & 1.7, 32-bit & 64-bit). Now I have 3.

Upvotes: 0

palacsint
palacsint

Reputation: 28895

Check the (local) firewall rules on the machine. I bumped into the same issue one year ago and allowing local connections for Eclipse/Java solved the issue. (I've just found a note about this.)

Upvotes: 0

Fredrik
Fredrik

Reputation: 10656

I think you have both JUnit 3 and JUnit4 installed on your system and the project imports the wrong version of JUnit. This will cause all sorts of weird problems.

In your case it seems the code isnt being treated as tests at all, which makes sense if you are using JUnit3.

Check your buildpath to see which JUnit you are using.

Upvotes: 2

Related Questions