testng
testng copied to clipboard
IInvokedMethodListener and groupname
TestNG Version
7.3.0 testNg.xml file I will add down (Runtime we are creating it)
Expected behavior
it is traversing through all TestNG classes and finding the group and it should not take the testNG class data members whose group name is not added.
Actual behavior
it is traversing through all TestNG classes and finding the group but along with that, it is taking the testNG class data members whose group name is not added.
Is the issue reproducible on a runner?
Its always
Test case sample
Wanted to know is it expected behavior or not
@Jitu1888 - Please edit the issue and add some context on what exactly is the problem. From what you have added, its not clear what is the issue you are facing.
The attached zip does not contain any information with respect to:
- A simple standalone example that can be used to reproduce the problem.
- No version information in terms of what TestNG version you are using. The latest released version of TestNG is
7.4.0
. Please ensure you use that and see if you are still able to reproduce the problem. Issues with previous versions cannot be fixed.
- I have attached the testNg.xml file.
- There I have included a group name and added all the testNG classes.
- Some testNG classes have some data members but the group name is not present in that TestNG class.
- While executing the attached XML, it is taking the last TestNG class and instantiates the data members. For example
public class FTUpiIntentTest extends BaseTest {
private int userBalance = 100;
PlayerUtil playerUtil = new PlayerUtil(getTestExecutionContext());
FTUpiIntentBL ftUpiIntentBL=new FTUpiIntentBL();
private static String phonePe = "phone-pe.apk";
private static String hdfcBank = "hdfc-mobilebanking.apk";
private static String iciciBank = "icicibank-pockets.apk";
private String s3AutoBucketUrl = new PlayerUtil(getTestExecutionContext()).getPropValue(API.CONFIGS,"s3AutoBucketUrl");
@Test(groups = { "a-upiIntent", "a-FtRegression", "i-upiIntent" })
public void verifyListOfUPIAppInstalledTest(){
HashMap<PlayerUtil.RegistrationDetails, String> userData = (HashMap<RegistrationDetails, String>) playerUtil.setupUserForUPITest();
PlayerUtil.downloadApkFilesFromS3Bucket(phonePe, s3AutoBucketUrl + phonePe);
ftUpiIntentBL.installPhonepeApp();
new FTLoginBL().loginUsing(userData.get(PlayerUtil.RegistrationDetails.USERNAME),
userData.get(PlayerUtil.RegistrationDetails.PASSWORD))
.startFTDAddCash().verifyListOfUPIPaymentModes(userBalance);
ftUpiIntentBL.removePhonepeApp();
}
But in parallel.xml I have added "a-jitu". So the above testNG class should be skipped and it should not run the data members of that class right (PlayerUtil(getTestExecutionContext()).getPropValue(API.CONFIGS,"s3AutoBucketUrl");).
Please correct me if I am wrong.
@krmahadevan
Please let me know if u need any more information @krmahadevan . I just wanted to know the behavior.
@Jitu1888 - Ok so if I understand your question correctly, you are basically expecting the following:
I have "x" number of classes in my suite xml, and I have specified a particular group say "foo". You are expecting that TestNG should instantiate ONLY those classes out of the entire "x" classes, which satisfy the basic expectation of it having one or more methods that belong to the group "foo"
Is this your expectation ?
If my understanding of your expectation is correct, then AFAIK TestNG does not work that way. TestNG would instantiate all classes that you have specified but it would use the groups that you specified to filter out methods for execution.
So in a nutshell, groups filtering is meant to filter out what to execute and NOT to filter out what to instantiate and what to skip.
So all the classes are going to be instantiated all the time irrespective of whether it has any methods that belong or are absent from the selected group in question.
Let me know if that answers your question
But with TestNG version 6.14.3: Behavior was different, there it did not instantiate the classes which were not specified with groups. Yesterday only I updated the testNG version then I faced some issues. @krmahadevan
@Jitu1888 - In that case, please do the following:
Create a sample Maven/Gradle project with some code that can be used to reproduce the problem, along with the expected and actual outputs.
Note: Please donot attach your full fledged tests that use selenium/appium/restassured etc., because we cannot run them. Also please ensure that the code in the sample project compiles.
ok @krmahadevan give me some time, I will share a demo project with u. Thanks for your quick response
@Jitu1888 - Sure thing no worries. Take your time. But please do help in sharing a proper reproducible sample so that its easy to dig into what broke where and see how we can fix it.
No response from the user. Closing this issue. Please comment if the problem can be reproduced with a sample project using the latest released version (7.6.1
as of today)