TestNG Programmatically use xml configuration

Fueled By Coffee

I'm wondering how I can write a program to run TestNG tests, still using the testng.xml file. For example, how do I make a class that can do this:

TestNG ng = new TestNG();
//ng.setTests("testng.xml") or something similar
ng.run();

I've looked at the documentation, but it's not very detailed, so I'm not sure if this is possible. Obviously, the comment should be replaced with the actual code to use the testng.xml file.

Do I need to use the TestNG configure method? Or does TestNG already have a method that does this that I missed?

elrobe

I'm sure there are other options out there, but you could use:

TestNG ng = new TestNG(); 
String[] arg = {"testng.xml"};
ng.main(arg);

and that should work fine. It's the same as running TestNG from the command line with the xml file as the argument.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

TestNG Programmatically use xml configuration

From Dev

Programmatically run specific TestNG method with virtual xml

From Dev

Running testng programmatically without XML throw NoSuchMethodError XmlPackage

From Dev

Set web.xml configuration programmatically

From Dev

TestNG: how do I run a custom TestNG.XML File programmatically

From Dev

Could i use @Parameters from TestNG to read from a user defined xml and not from testng.xml

From Dev

unable to run testng xml when I use groups

From Dev

TestNG conditional configuration methods

From Dev

Unable to use splitterChannel with advanced xml configuration with poco

From Dev

TestNG XML execution order

From Dev

TestNG set of values in XML

From Dev

How to use an EditText, defined in xml, in a programmatically built page

From Dev

How to use RippleDrawable programmatically in code (not xml) with Android 5.0 Lollipop?

From Dev

How to use an EditText, defined in xml, in a programmatically built page

From Dev

Programatically skip configuration method in TestNG

From Dev

Programmatically check the build configuration

From Dev

Programmatically check the build configuration

From Dev

How do I use groups 'depends-on' in my testng.xml config file?

From Dev

use LINQ to XML to Programmatically get all differences between 2 xml files

From Dev

Adding system property in testng XML?

From Dev

parameters passing in testNG.xml

From Dev

how to disable cas if I use web.xml configuration

From Dev

Change xml value programmatically

From Dev

create xml with attributes programmatically

From Dev

Comment xml elements programmatically

From Dev

How to use testng annotations in java

From Dev

How to use TestNg in Selenium WebDriver?

From Dev

Programmatically getting Jenkins configuration for a plugin

From Dev

How to set ImageResizer configuration programmatically?

Related Related

  1. 1

    TestNG Programmatically use xml configuration

  2. 2

    Programmatically run specific TestNG method with virtual xml

  3. 3

    Running testng programmatically without XML throw NoSuchMethodError XmlPackage

  4. 4

    Set web.xml configuration programmatically

  5. 5

    TestNG: how do I run a custom TestNG.XML File programmatically

  6. 6

    Could i use @Parameters from TestNG to read from a user defined xml and not from testng.xml

  7. 7

    unable to run testng xml when I use groups

  8. 8

    TestNG conditional configuration methods

  9. 9

    Unable to use splitterChannel with advanced xml configuration with poco

  10. 10

    TestNG XML execution order

  11. 11

    TestNG set of values in XML

  12. 12

    How to use an EditText, defined in xml, in a programmatically built page

  13. 13

    How to use RippleDrawable programmatically in code (not xml) with Android 5.0 Lollipop?

  14. 14

    How to use an EditText, defined in xml, in a programmatically built page

  15. 15

    Programatically skip configuration method in TestNG

  16. 16

    Programmatically check the build configuration

  17. 17

    Programmatically check the build configuration

  18. 18

    How do I use groups 'depends-on' in my testng.xml config file?

  19. 19

    use LINQ to XML to Programmatically get all differences between 2 xml files

  20. 20

    Adding system property in testng XML?

  21. 21

    parameters passing in testNG.xml

  22. 22

    how to disable cas if I use web.xml configuration

  23. 23

    Change xml value programmatically

  24. 24

    create xml with attributes programmatically

  25. 25

    Comment xml elements programmatically

  26. 26

    How to use testng annotations in java

  27. 27

    How to use TestNg in Selenium WebDriver?

  28. 28

    Programmatically getting Jenkins configuration for a plugin

  29. 29

    How to set ImageResizer configuration programmatically?

HotTag

Archive