Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

TestNG sequential testing config file is NOT working as expected

36 views
Skip to first unread message

Prasad Nutalapati

unread,
Aug 26, 2024, 11:14:26 AM8/26/24
to testng-users
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" preserve-order="true" parallel="none" thread-count="1">

<test name="RealLocalDeviceTesting">

<classes>

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


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

</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: 87.72 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:29 min

    [INFO] Finished at: 2024-08-26T10:04:57-05:00

    [INFO] [1m------------------------------------------------------------------------ [m

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


    Prasad Nutalapati

Grigoriy Frank

unread,
Aug 26, 2024, 12:14:46 PM8/26/24
to testng...@googlegroups.com

I think it is because name of the parameter is not unique.  For example, 'MaterialNbr'. You defined it two times and testNG set the last value for it. You shoud  have separate test for each set of parameters or use a data provider.


пн, 26 авг. 2024 г., 23:14 Prasad Nutalapati <pnuta...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/f6bcca4b-a0cb-43ea-862d-96eb03cd204fn%40googlegroups.com.

Prasad Nutalapati

unread,
Aug 27, 2024, 9:28:14 AM8/27/24
to testng-users
Hello,
Thanks for your suggestion/reply
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="RealLocalDeviceTesting"> -->

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


Prasad Nutalapati

Reply all
Reply to author
Forward
0 new messages