Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/org/mockito/testng/MockitoTestNGListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;

import org.mockito.InjectMocks;
Expand Down Expand Up @@ -82,8 +83,8 @@
*/
public class MockitoTestNGListener implements IInvokedMethodListener {

private final Map<Object, MockitoSession> sessions = new HashMap<>();
private final Map<Object, Map<InstanceField, Object>> injectMocksFieldsValues = new HashMap<>();
private final Map<Object, MockitoSession> sessions = new ConcurrentHashMap<>();
private final Map<Object, Map<InstanceField, Object>> injectMocksFieldsValues = new ConcurrentHashMap<>();

@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/mockitousage/testng/ParallelMethodTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2017 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockitousage.testng;

import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

@Listeners(MockitoTestNGListener.class)
public class ParallelMethodTest {

@Test(threadPoolSize = 4, invocationCount = 8)
public void testParallel() {
// nothing to do here, the execution just shouldn't fail
}

}