NewTester
NewTester

Reputation: 3

TestNG sequential testing config file is NOT working as expected

I am trying to run two distinct test runs using the same code base: One for Android device and another for an iOS device. I am using parameters to pass some String values to feed the test cases. This is a Maven project in which I am declaring the TestNG.xml file with in the pom.xml file at **<plugin> <suiteXmlFile>** I have tested the similar config in running a bare bones Java class as a POC for the functionality. I am using the latest TestNG at v7.10.2, JDK at 21. Here is the config file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="zCommerce_Test_Suite" parallel="methods"  preserve-order="true" thread-count="1">
    <test name="RealLocalDeviceTesting">
    
    <parameter name = "MaterialNbr" value="5521000">
    **<classes>**
        
       *<**class*** name="com.zq.mobile.browser.test.OpenTextSearchOnlineOrdering">
           <parameter name = "platform" value="iOS"/>
           <parameter name = "browser" value="Safari"/>
           <parameter name = "device" value="Venkata Nutalapati's iPhone"/>
           <parameter name = "udid" value="00008030-000159EA0E60402E"/>
           <parameter name = "platformVersion" value="17.5.1"/>
           *</**class**>*
        
           *<**class*** name="com.zq.mobile.browser.test.OpenTextSearchOnlineOrdering">
           <parameter name = "platform" value="Android"></parameter>
           <parameter name = "browser" value="Chrome"></parameter>
           <parameter name = "device" value="Galaxy S21 FE 5G"></parameter>
           <parameter name = "udid" value="R5CW71PYTHE"></parameter>
           <parameter name = "platformVersion" value="14"></parameter>
           *</**class**>*

    **</classes>**
    </parameter>
    </test> 
</suite>

I am expecting the test class be run with each set of parameters(iOS, and Android). All the parameters are being passed just fine to the class during run time, when I run the config with just either one of the class. Whether I change the order of the class tag, or not, it always is running the second class set ONLY, but I don't understand why ??

What is the mistake I have to correct in the config xml file syntax ??

  1. I tried checking whether the parameter string values are being passed when either of the test cases are running, which is postive whether it is for Android case or iOS case.

  2. I tried shifting the order of the two class tag contents like from 1-2 to 2-1, it is always choosing to run the test case with second tag only.

  3. I tried removing the <suite> arguments 'parallel', 'thread-count', but no help

  4. I am seeing it is executing only one test case as shown below.

        **isTestPassed=true 
        [INFO] [1;32mTests run: [0;1;32m1[m, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 91.04 s -- in [1mTestSuite[m [INFO]
    
      [INFO] Results: [INFO]  
    
    [INFO] [1;32mTests run: 1, Failures: 0, Errors: 0, Skipped: 0[m [INFO]
    

[INFO] [1m------------------------------------------------------------------------[m
[INFO] [1;32mBUILD SUCCESS[m [INFO] [1m------------------------------------------------------------------------[m
[INFO] Total time: 01:32 min [INFO] Finished at: 2024-08-25T18:38:26-05:00 [INFO]
[1m------------------------------------------------------------------------[m**

I am hoping to make the TestNG run both the test classes using the corresponding parameter string values.

Upvotes: 0

Views: 42

Answers (1)

NewTester
NewTester

Reputation: 3

I could able to resolve the issue by wrapping each classes tag with test tag and achieve the effect of running each of the test one after another in sequence, which is what I am trying to do. Please see the xml snippet.

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">    
<suite name="zCommerce_Test_Suite" preserve-order="true" parallel="none" thread-count="1">    
    <test name="RealLocalDeviceiOSTesting">
    <classes>
    <class name="com.zq.mobile.browser.test.PurchaseOrderCreation" /> 
        <class name="com.zq.mobile.browser.test.DeliveryDocumentNbrValidation" />    
       <class name="com.zq.mobile.browser.test.OpenTextSearchOnlineOrdering">    
       <parameter name = "MaterialNbr" value="5521000"/>     
            <parameter name = "platform" value="iOS"/>     
            <parameter name = "browser" value="Safari"/>    
            <parameter name = "device" value="Venkata Nutalapati's iPhone"/>  
            <parameter name = "udid" value="00008030-000159EA0E60402E"/>    
            <parameter name = "platformVersion" value="17.5.1"/>     
            </class>     
      </classes>    
      </test>  
      
        <test name="RealLocalDeviceAndroidTesting">    
            <class name="com.zq.mobile.browser.test.PurchaseOrderCreation" />     
            <class name="com.zq.mobile.browser.test.DeliveryDocumentNbrValidation" />     
        <classes> 

            <class name="com.zq.mobile.browser.test.OpenTextSearchOnlineOrdering">    
            <parameter name = "MaterialNbr" value="5521000"/>    
            <parameter name = "platform" value="Android"></parameter>    
            <parameter name = "browser" value="Chrome"></parameter>    
            <parameter name = "device" value="Galaxy S21 FE 5G">/parameter>     
            <parameter name = "udid" value="R5CW71PYTHE"></parameter>     
            <parameter name = "platformVersion" value="14"></parameter>    
            </class>
          </classes>
         </test>
        </classes>
    </test>
</suite>

Upvotes: 0

Related Questions