testng icon indicating copy to clipboard operation
testng copied to clipboard

IInvokedMethodListener and groupname

Open Jitu1888 opened this issue 3 years ago • 10 comments

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 avatar Dec 16 '21 08:12 Jitu1888

parallel.xml.zip

Jitu1888 avatar Dec 16 '21 08:12 Jitu1888

@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:

  1. A simple standalone example that can be used to reproduce the problem.
  2. 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.

krmahadevan avatar Dec 16 '21 08:12 krmahadevan

  1. I have attached the testNg.xml file.
  2. There I have included a group name and added all the testNG classes.
  3. Some testNG classes have some data members but the group name is not present in that TestNG class.
  4. 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.

Jitu1888 avatar Dec 16 '21 08:12 Jitu1888

@krmahadevan

Jitu1888 avatar Dec 16 '21 08:12 Jitu1888

Please let me know if u need any more information @krmahadevan . I just wanted to know the behavior.

Jitu1888 avatar Dec 16 '21 08:12 Jitu1888

@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

krmahadevan avatar Dec 16 '21 08:12 krmahadevan

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 avatar Dec 16 '21 08:12 Jitu1888

@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.

krmahadevan avatar Dec 16 '21 08:12 krmahadevan

ok @krmahadevan give me some time, I will share a demo project with u. Thanks for your quick response

Jitu1888 avatar Dec 16 '21 08:12 Jitu1888

@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.

krmahadevan avatar Dec 16 '21 08:12 krmahadevan

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)

krmahadevan avatar Nov 04 '22 16:11 krmahadevan