--
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+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
@BeforeSuitepublic void initTestProg(ITestContext context) throws InterruptedException { XmlSuite xmlSuite = context.getCurrentXmlTest().getSuite(); // Create an instance of XmlTest and assign a name for it.
XmlTest xmlTest = new XmlTest(xmlSuite); xmlTest.setName("Sample Test");
// Create a list which can contain the classes that you want to run. List<XmlClass> myClasses = new ArrayList<XmlClass>(); myClasses.add(new XmlClass("testing.testngtst.Basic1")); myClasses.add(new XmlClass("testing.testngtst.Basic2"));
// Assign that to the XmlTest Object created earlier. xmlTest.setXmlClasses(myClasses); //....(more code here)
testNG.setXmlSuites(mySuites); testNG.run();
}
It might be but it's not supported, so the behavior is undefined.Adding tests dynamically is typically performed by factories or data providers, wouldn't that work for you?
--Cédric
On Mon, May 8, 2017 at 2:12 PM, Tatery <tatery...@gmail.com> wrote:
@Cedric is there a way to modify testNg context at runtime? This would be really nice feature :)
W dniu poniedziałek, 8 maja 2017 10:37:14 UTC+2 użytkownik Tatery napisał:Hello,I'd like to execute tests using testng xml and maven but in addition to that some tests have to be run programmatically. It means that some tests from xml suite have to run other tests programmatically and afterwards I'd like to have only one test report.Do you know if something like this is possible?
--
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.
With this code, you would run a TestNG inside a TestNG. It would work but the reports at the end would probably be confusing.
Maybe you could take over the whole process and in your own main()
, create an XmlSuite
that is the sum of testng.xml
and your own programmatically created tests, and then invoke testng.run()
.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
@Tatery
I think you can try upgrading to the latest version of TestNG and then try leveraging the listener IAlterSuiteListener. This interface let's you alter the suite contents programmatically via listeners.
Please see this thread for more info.
https://groups.google.com/forum/m/#!topic/testng-users/u4HwjBEUzhY
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
If ReportNG is generating reports via an implementation of IReporter interface implementation then this should not happen. If it's doing via some other listener implementation mechanism then yes it could very well be possible.
<configuration>
<suiteXmlFiles>
<suiteXMLFile>testng.xml</suiteXMLFile>
</suiteXmlFiles>
<suite name="HourlyTest">
<test name="OnDemandTest"> <classes> <class name="com.auto.DummyTest" />
</classes>
</test>
</suite>
Please upgrade to the latest released version of TestNG viz., 6.14.3 and use org.testng.IAlterSuiteListener for your usecase.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--