You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to use IInvokedMethodListener to break reporting into different blocks for Selenium testing which is multithreaded and run in parallel.
TestNG Version
Version: 7.9.0
Expected behavior
During @BeforeMethod, @AfterMethod and @AfterClass the corresponding instance of test object to be returned via ITestResult.getInstance() or IInvokedMethod.getTestMethod().getInstance() is incorrect
Actual behavior
returns the wrong instance during @BeforeMethod, @AfterMethod and @AfterClass in IInvokedMethodListener listeners
Is the issue reproducible on runner?
Shell
Maven
Gradle
Ant
Eclipse
IntelliJ
NetBeans
Test case sample
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel IconfigListener test">
<test name="Parallel IConfigListener test" group-by-instances="true" parallel="instances">
<classes>
<class name="org.example.MainTest"/>
</classes>
</test>
</suite>
test class
import java.util.Arrays;
import java.util.HashMap;
@Listeners(value = {methodListener.class})
public class MainTest {
public HashMap<String, Integer> hashMap = new HashMap<>();
@Factory(dataProvider = "dataProvider")
public MainTest() {
}
@DataProvider
public static Object[][] dataProvider() {
Object[][] objects = new Object[2][];
Arrays.fill(objects, new Object[0]);
return objects;
}
@BeforeClass
public void beforeClass() {
assertHashCode("beforeClass");
}
private void assertHashCode(String methodName) {
Assert.assertEquals(hashMap.get(methodName), hashCode());
}
@BeforeMethod
public void beforeMethod() {
assertHashCode("beforeMethod");
}
@AfterMethod
public void afterMethod() {
assertHashCode("afterMethod");
}
@Test
public void testMethod() {
assertHashCode("testMethod");
}
@AfterClass
public void afterClass() {
assertHashCode("afterClass");
}
}
Trying to use IInvokedMethodListener to break reporting into different blocks for Selenium testing which is multithreaded and run in parallel.
TestNG Version
Version: 7.9.0
Expected behavior
During
@BeforeMethod
,@AfterMethod
and@AfterClass
the corresponding instance of test object to be returned viaITestResult.getInstance()
orIInvokedMethod.getTestMethod().getInstance()
is incorrectActual behavior
returns the wrong instance during
@BeforeMethod
,@AfterMethod
and@AfterClass
inIInvokedMethodListener
listenersIs the issue reproducible on runner?
Test case sample
test class
Listener
The text was updated successfully, but these errors were encountered: