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

Test run in multiple threads #20

Open
slawekjaranowski opened this issue Nov 28, 2020 · 2 comments
Open

Test run in multiple threads #20

slawekjaranowski opened this issue Nov 28, 2020 · 2 comments

Comments

@slawekjaranowski
Copy link
Member

We can annotate test with:

    @Mock
    private MyType mock;

    @Test(threadPoolSize = 3, invocationCount = 8)
    public void testParallel() {
     ....
    }

In this case MockitoTestNGListener will not work as we want.
In current implementation MockitoSession is bind to current test instance, but TestNG create one test instance and run test in multiple thread.

Issue need more investigate how to resolve problem.

We must to check and discover how mocked field should be distinguished on one test instance and multiple thread.

Please like / react on issue to we see how many people are interested this issue.

@slawekjaranowski
Copy link
Member Author

This testng-team/testng#1872 is probably connected.

@mlieshoff
Copy link

I strongly guess it throws ConcurrentModificationExceptions because of the usage of HashMaps instead of ConcurrentHashMaps in the MockitoTestNGListener class. The (not thread safe) handling of the fixtures seems to be a problem in the framework and related to the referenced issue. But at least the listener itself could be thread safe with changing the Map implementation and make life a bit easier :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants