How to use the TestNG XML Generator
- 1. List the classesFully qualified test classes, one per line.
- 2. Set how to runOne test block, one per browser or one per class; parallel mode, threads, groups, parameters and listeners.
- 3. GenerateDownload testng.xml and run it from Maven or your IDE.
What the settings do
A TestNG suite contains one or more <test> blocks, each listing classes. Choosing one per browser repeats your classes in a block per browser, with a browser parameter your setup method reads through @Parameters("browser"); that's the usual way to run a suite on Chrome and Firefox. parallel="tests" runs those blocks at the same time, classes and methods go finer, and thread-count caps the threads. Groups filter methods by their @Test(groups = …) tags. Every value is escaped for XML, so characters like & and < in parameters are safe. Everything runs in your browser; nothing you enter is uploaded.
Worked example
The sample has three classes (login, enrolment and receipt tests), browsers chrome, firefox, parallel tests with 2 threads, groups smoke and regression included and flaky excluded, plus baseUrl and timeout parameters. The result has 2 <test> blocks, Chrome tests and Firefox tests, each with all 3 classes, running side by side. All six combinations of block style and parallel setting were checked as well-formed XML.
Tips
- With parallel methods, keep each thread's WebDriver in a
ThreadLocal. - Start with 2–4 threads; more threads than CPU cores rarely helps browser tests.
- Point Maven Surefire at the file with
<suiteXmlFiles>.
Frequently asked questions
Why the https DTD address?
Recent TestNG versions expect https://testng.org/testng-1.0.dtd and can refuse the old http address.
Can I run only smoke tests?
Yes. Put smoke in Include groups and leave the rest empty.
Is the TestNG XML generator free?
Yes. You can open the TestNG XML generator and fill in everything without signing up. When you generate the file for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.