dimanche 2 avril 2017

Is there a way to ignore a test completely based on a condition (if a parameter does not exist in the test)

Below is my TestNG suite xml file.

<test name="m_AggregatorTx">
            <parameter name="logFile" value="hadoopmslogs/${Domain_Name}/${NODENAME}/Hive_961/m_AggregatorTx.log"/>
            <classes>
                    <class name="executems.main.RunMS"></class>
            </classes>
    </test>

    <test name="m_alldt">
            <parameter name="logFile" value="hadoopmslogs/${Domain_Name}/${NODENAME}/Hive_961/m_alldt.log"/>
            <parameter name="enableUT" value="true"/>
            <classes>
                    <class name="executems.main.RunMS"></class>
            </classes>
    </test>

    <test name="m_alldt_cpx">
            <parameter name="logFile" value="hadoopmslogs/${Domain_Name}/${NODENAME}/Hive_961/m_alldt_cpx.log"/>
            <classes>
                    <class name="executems.main.RunMS"></class>
            </classes>
    </test>


<test name="m_alldt_custom_query_prop">
            <parameter name="logFile" value="hadoopmslogs/${Domain_Name}/${NODENAME}/Hive_961/m_alldt_custom_query_prop.log"/>
            <parameter name="enableUT" value="true"/>
            <classes>
                    <class name="executems.main.RunMS"></class>
            </classes>
    </test>

In runtime, I want to ignore the tests which do not have enableUT parameter in it. For example, in the above suite file m_AggregatorTx and m_alldt_cpx do not have enableUT parameter in them.

Note: 1. I do not want to add enabled=true/false to my suite xml. ( Because I have 30 different suite files which have 100 test cases each) 2. Currently during runtime, I am able to Skip these tests using throw new SkipException. But once a run finishes, the results comes as this:

=============================================== Hive_961

Total tests run: 4, Failures: 0, Skips: 2

  1. I do not want the two cases to show up in the Skips section in the result. I want those cases to be ignored during run-time. I want the result something like this:

=============================================== Hive_961

Total tests run: 2, Failures: 0, Skips: 0

if(enableBugB.equals("true"))
            {
                    System.out.println("enableBugB is set to true in this Test Case");
                    boolean result = Services.runMapping(applicationName, mappingName, database, runID);
                    if(runID != null && !runID.isEmpty())
                    {

                        VerifyMapping.compareResults(verifyXml, runID, logPath,result);
                    }
                    else
                    {

                        VerifyMapping.compareResults(verifyXml, mappingName, logPath,result);
                    }
                }
                else
                {
                    //System.out.println("enableBugB is not present for this Test. Hence skipping this Test Case..");
                    throw new SkipException("enableBugB is not enabled. Skipping this Test Case..");

                }

Appreciate any help. Thanks.

Aucun commentaire:

Enregistrer un commentaire