Ask a Question

How to Execute Testng Suite (Testng.xml) with QA complete without TestComplete?

SOLVED
raja2
Contributor

How to Execute Testng Suite (Testng.xml) with QA complete without TestComplete?

Hi Team,

 

I want to execute TestNG Suite (TestNG.xml) file from QA complete without TestComplete.   Please find the attached screenshot.

 

  • Is it possible to run the testng suite ?
  • I have created a testng suite with "n" number of java classes in it
  • How can i execute such suite.xml in QA complete ?
  • Can i execute directly testng suite.xml without mentioning all the classes in it in Automation ?

Can i execute testng suite.xml file from Custom Args: ?

 

Thanks in Advance !

 

Regards,

Poovaraj

14 REPLIES 14
Nastya_Khovrina
SmartBear Alumni (Retired)

Hi Poovaraj,

 

Thank you for your post!

When you specify a Test Class in QAC Automation, Test Agent generates a command line like this:

java org.testng.TestNG -testclass MyPack.MyClass

 

To run a TestSuite you need the command line like this:

java org.testng.TestNG testng1.xml

 

So, don't specify the Test Class (leave this field empty) and fill the Custom Args field with the name of your Test Suite. Please see a sample screenshot attached.

 

Workaround: user can configure a Maven project to run a TestNG test suite (http://testng.org/doc/maven.html), and then run this Maven project from QAC.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

 

Thanks for your reply. It is working fine 

shirishnagar
Occasional Contributor

Hi Poovaraj,

 

I am facing similar issue,

 

having working TestNG framework with Maven in one of the VMM. Have to configure to make it run through QA Complete, can you please highlight some tips how exactly has to configure.

 

I did the below thing

- Configure the TestAgent (hope I did it right)

- then add new row in one of the TCs in automation tab

- Zipped the Project folder (TestNG-Maven) and upload it to QA complete while adding new row.

Checked the checkbox for Maven

- Configure and then schedule it

 

as per schedule time, something is happening it results fail. I am observing that it initiates command prompt but get close in few seconds and results as FAIL in the run history.

 

Also can you please confirm if this settings in attached snapshot are correct are not?

[^TestRunner.JPG]

 

 

Any suggestion will be appreciable.

 

Regards,

Shirish

 

Hi Shirish,

 

Please find the attached Test Agent setting and Maven configuration snapshot. Please let me know if you need any help.

 

File Name : I am giving Maven Project Folder Path

 

Maven Project configured in TestMaven Project configured in TestTest AgentTest Agent

 

Regards,

Poovaraj

 

shirishnagar
Occasional Contributor

Thanks Poovaraj for reply.

 

Is your maven project folder path is till the file name i.e. file:///C:/Users/........./File.java or till 1st folder of the maven project hierarchy like file:///C:/Users/........./AutomationFolder.

 

Auto.JPG

 

I tried both but nothing worked for me 🙂

 

 

Few more questions

  • In TCs in QA complete, other than configuring the aforesaid snapshot, are you doing any thing else?
    • With the TCs I am linking configuration and schedule, is there anything else that I need to take care?
  • in TestAgent, are you providing Username and password. In my case, Administrator is the username of my VM where my Automation stuffs reside but my QA complete credentials are different than this credentials.

 

TestAgent.JPG

 

  • Any way to certify that agent is working successfully?

 

 

 

shirishnagar
Occasional Contributor

Hi Poovaraj,

 

Finally it worked for me. I mapped Maven folder in the execution (top most folder in the maven project hierarchy) and change the JAVA path, it worked. 

 

Few questions from the current behavior of execution, will be appreciable if you can answer these queries

 

  • Like others, my framework has multiple TestNG classes and each class has multiple @Test methods
  • Since folder has multiple TestNG classes, it is executing all.
    • Is there any way to execute particular class only?
    • Is there any way to map @Test method with particular TC in QA complete, so that when running particular TC in QA complete, it executes that specific TC rather than all.
  • Currently in my pom.xml, I have defined only 1 profile which ideally calling only 1 class so while executing from QA complete, it executes all classes under maven folder i.e. not taking the pom.xml into consideration.
    • Any suggestions on this?

Thanks in anticipation.

 

Regards,

Shirish

Hi Shirish,

 

I am executing single class file using below method. 

 

(1) Executing single java class file using testng.xml file (without using Maven project)

 

Step 1  : Need to configure required java class file in testng.xml file

Step 2 :  Executing testng.xml file from QAC

 

<?xml version="1.0" encoding="UTF-8"?>
<suite name="example suite 1" verbose="1" >
<test name="Regression suite 1" >
<classes>
<class name="com.first.example.demoOne"/>
</classes>
</test>
</suite>

 

(2) Executing single java class file using testng.xml file and Maven project

 

Step 1  : Need to configure required java class file in testng.xml file.

Step 2 :  Need to configure testng.xml file in POM.xml 

   

Reference Link : http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

 

<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
[...]
</plugins>

 

Step 2 :  Executing Maven project from QAC

 

<?xml version="1.0" encoding="UTF-8"?>
<suite name="example suite 1" verbose="1" >
<test name="Regression suite 1" >
<classes>
<class name="com.first.example.demoOne"/>
</classes>
</test>
</suite>

 

Regards,

Poovaraj

Hi Poovaraj,

 

Thanks a ton for reply, its much appreciable. I tried the way you have mentioned but its not working.

 

At initial I doubt for Test agent configuration but I think its correct as if I check maven project checkbox, it executes the TC (executing all classes is another issue) :).

 

With the case of non-maven execution, I have

 

  • Java run time, java class path mentioned in Test AgenTestAgent2.JPG
  •  
  • testng.xml is configured with 1 test class as below

    <?xml version="1.0" encoding="UTF-8"?>
    <suite name="Regression TestSuite" verbose="1" >

    <test name="InvoiceNotes">
    <classes>
    <class name="tcsLoginScreen.LoginLogoutTest"></class>
    </classes>
    </test>
    </suite>

  • Configured Automation TC as below, 
  • Config.JPG
  • The testng.xml is placed at the path mentioned above in snapshot,
  • As I run TC from automation, it updated the status to Passed after few seconds but it is not invoking any  browser, 
  • Do you suggest any more changes into this?

Regards,

Shirish

Hi Poovaraj,

 

Finally it worked with individual class with and without maven.

 

1 more question, it is possible to execute individual @Test from the class which has multiple @Test methods?

 

Regards,

Shirish

cancel
Showing results for 
Search instead for 
Did you mean: