Eclipse and Unrooted Tests With MockitoJUnitRunner

882 views
Skip to first unread message

Stephen Duncan Jr

unread,
Jul 27, 2009, 3:42:42 PM7/27/09
to moc...@googlegroups.com
When I try to run a single test in Eclipse on a test class that has the @RunWith(MockitoJUnitRunner.class) annotation, it runs all the tests underneath a group called "Unrooted Tests".  If remove the @RunWith annotation and add the MockitoAnnotations.initMocks(this) call to my setup, then I can run a single test as usual.  This also happens with the deprecated MockitoJUnit44Runner, and it happens with either JUnit 4.4 (what I'm primarily using due to an incompatiblity between Spring and JUnit 4.5+) and with JUnit 4.6.

One person's post on this thread indicated that it can potentially be caused by a faulty runner implementation: http://www.nabble.com/Re%3A-what%27s-an-%22Unrooted-Test%22-and-why-can%27t-I-find-anything-online-about-it--p14663780.html

One piece of data indicating it's likely a problem in the 1.8.0 MockitoJUnitRunner: this problem doesn't occur in Mockito 1.7.  In 1.7 only the single test is run if I use either of these combinations: 1) MockitoJUnit44Runner and JUnit 4.4 or 2) MockitoJunitRunner and JUnit 4.6.

--
Stephen Duncan Jr
www.stephenduncanjr.com

szczepiq

unread,
Jul 27, 2009, 5:23:41 PM7/27/09
to moc...@googlegroups.com
Hi,

Are you saying my runner is bad? Grrr.... :)

So, I cannot reproduce it with Eclipse 3.4.0 (Build id:
I20080617-2000). I tried with mockito-all 1.8 + jUnit 4.4 / jUnit 4.6,
running single test, single method, etc. All good.

What are the exact steps you perform?

Cheers,
Szczepan Faber

Stephen Duncan Jr

unread,
Jul 27, 2009, 9:53:27 PM7/27/09
to moc...@googlegroups.com
:) It's probably a problem with Eclipse as well...

With Eclipse 3.5 (Build id: 20090619-0625), using the following code:

package test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class UnrootedTest {
    @Test
    public void test1() {
        assert true;
    }
   
    @Test
    public void test2() {
        assert true;
    }
}

Running just test1 shows up as:

test1
Unrooted Tests
   test2

-Stephen

szczepiq

unread,
Jul 28, 2009, 3:57:53 PM7/28/09
to moc...@googlegroups.com
Hi,

I got hold of 20090619-0625 (BTW it's quite fast and neat =) and I can
confirm weird behavior with unrooted tests. I wonder how this
behaviour is annoying to you, e.g. is it enough to provide us a patch?
:)

Cheers,
Szczepan Faber

On Tue, Jul 28, 2009 at 3:53 AM, Stephen Duncan

Stephen Duncan Jr

unread,
Jul 28, 2009, 9:29:38 PM7/28/09
to moc...@googlegroups.com
It's a minor issue, and I'm not familiar with the code in question (JUnit runners or MockitoJUnitRunner), it may be a while before it itches enough for me to work towards scratching it and trying to fix it myself.  I was hoping that the change from it working in 1.7 to not-working in 1.8 would be enough to make it easier to solve... :)

Should I file an issue now, and work towards the patch as possible later if still necessary?

-Stephen

szczepiq

unread,
Jul 29, 2009, 3:59:04 AM7/29/09
to moc...@googlegroups.com
> hoping that the change from it working in 1.7 to not-working in 1.8 would be
> enough to make it easier to solve... :)

I'll have a look.

> Should I file an issue now, and work towards the patch as possible later if
> still necessary?

Sure. That would be helpful, thanks!

Cheers,
Szczepan Faber

On Wed, Jul 29, 2009 at 3:29 AM, Stephen Duncan
Reply all
Reply to author
Forward
0 new messages