Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringJUnit4ClassRunner.createTest() is called twice. #160

Closed
m15o opened this issue Apr 7, 2015 · 1 comment
Closed

SpringJUnit4ClassRunner.createTest() is called twice. #160

m15o opened this issue Apr 7, 2015 · 1 comment
Assignees
Labels
bug

Comments

@m15o
Copy link

@m15o m15o commented Apr 7, 2015

When I use jmockit with SpringJUnit4ClassRunner, somehow createTest() is called twice. It causes initialization issue to some TestExecutionListener.

This is a example test case to reproduce this issue.

import mockit.Invocation;
import mockit.Mock;
import mockit.MockUp;

import org.junit.Ignore;

public class Test {
    @Ignore
    public static class BlockJUnit4ClassRunner {
        void createTest() {
            System.out.println("BlockJUnit4ClassRunner.createTest()");
        }
    }

    @Ignore
    public static class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
        @Override
        void createTest() {
            System.out.println("SpringJUnit4ClassRunner.createTest()");
            super.createTest();
        }
    }

    public static class BlockJUnit4ClassRunnerDecorator extends MockUp<BlockJUnit4ClassRunner> {
        @Mock
        public void createTest(Invocation invocation){
            System.out.println("BlockJUnit4ClassRunnerDecorator.createTest()");
            invocation.proceed();
        }
    }

    @org.junit.Test
    public void test() {
        new BlockJUnit4ClassRunnerDecorator();
        new SpringJUnit4ClassRunner().createTest();
    }
}

output

SpringJUnit4ClassRunner.createTest()
BlockJUnit4ClassRunnerDecorator.createTest()
SpringJUnit4ClassRunner.createTest()
BlockJUnit4ClassRunner.createTest()
@rliesenfeld rliesenfeld added the bug label Apr 7, 2015
@rliesenfeld rliesenfeld self-assigned this Apr 7, 2015
@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented Apr 7, 2015

Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.