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
ITestcontext.getAllTestMethods() with annotation @BeforeSuite returns the method names incorrectly from other test classes
Whole context of an issue
I have written logic to get all the enabled tests from the test classes and pass those enabled test names to other components that I use for my project.
Test cases are enabled via the testng.xml file using the <methods> tag[ with <include>] under <class>. If I don't pass <methods> tag, then all tests under that test class are enabled, and if I pass the tag, only those tests are enabled for execution.
I have 3 test classes which will have different test methods and all class should have the following code [To get the enabled test cases and pass those methods for other components in my project]
Test Class Name: CreateTests
Test Method Name: create
Test Class Name: UpdateTests
Test Method Name: update
Test Class Name: DeleteTests
Test Method Name: delete
@BeforeSuitepublicvoidpreConditionsSetUp(ITestContextpreSetupContext) {
ArrayList<String> enabledTestCasesList = newArrayList<>();
ITestNGMethod[] testNGMethod = preSetupContext.getAllTestMethods();
for (ITestNGMethodallMethods : testNGMethod) {
enabledTestCasesList.add(allMethods.getMethodName());
}
System.out.println("enabledTestCasesList in class 'UpdateTests' :: "+enabledTestCasesList);
}
My testng.xml file is like this
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPEsuite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suitename="QA Test Suite"verbose="1">
<testname="CreateTest">
<classes>
<classname="testcases.module1.CreateTests"/>
</classes>
</test>
<testname="UpdateTest">
<classes>
<classname="testcases.module1.UpdateTests"/>
</classes>
</test>
<testname="Delete">
<classes>
<classname="testcases.module1.DeleteTests"/>
</classes>
</test>
</suite>
When I execute above testng.xml, enabledTestCasesList any of 3 test classes, ITestcontext.getAllTestMethods() returns the method from last test case 'delete' instead 'create','update'.
TestNG Version
7.8.0
Issue
ITestcontext.getAllTestMethods()
with annotation @BeforeSuite returns the method names incorrectly from other test classesWhole context of an issue
I have written logic to get all the enabled tests from the test classes and pass those enabled test names to other components that I use for my project.
Test cases are enabled via the testng.xml file using the
<methods>
tag[ with<include>
] under<class>
. If I don't pass<methods>
tag, then all tests under that test class are enabled, and if I pass the tag, only those tests are enabled for execution.I have 3 test classes which will have different test methods and all class should have the following code [To get the enabled test cases and pass those methods for other components in my project]
My testng.xml file is like this
When I execute above
testng.xml
, enabledTestCasesList any of 3 test classes,ITestcontext.getAllTestMethods()
returns the method from last test case 'delete' instead 'create','update'.I've attached the test maven project here.
TestNGIssue.zip
TestNG Dev email conversation - https://groups.google.com/g/testng-dev/c/iM7Ot6pLyIg/m/zp3WqHq3AwAJ
The text was updated successfully, but these errors were encountered: