is it possible to reference non-existing file in testng.xml?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

is it possible to reference non-existing file in testng.xml?

Lan Xia

It seems testng.xml needs to be able to see the all test classes that are listed, even if we doesn't run those tests.


Our test material contains tests for different java releases in one repo. In following example, featureA_extra does not existing when testing our release1. 



<test name="testRelease1">

   <classes>

     <class name="org.test.featureA" />

     <class name="org.test.featureC" />

   </classes>

</test>

<test name="testRelease2">

   <classes>

     <class name="org.test.featureA_extra" /> <===== do not exist when testing release1

   </classes>

</test>


when run testRelease1 test, we got following error:


[TestNG] [ERROR]

Cannot find class in classpath: org.test.featureA_extra

Exception in thread "main" java.lang.NullPointerException

at org.testng.TestNG.getStatus(TestNG.java:211)

at org.testng.TestNG.main(TestNG.java:1324)


Is it possible to reference non-existing file in testng.xml? Is there a way to configure TestNG to skip verifying test classes in testng.xml, specially for test that we do not run? We would prefer to keep one testng.xml file and do not to want to create a dummy test file featureB.java when running test for release1.


Thanks,

     Lan




--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to reference non-existing file in testng.xml?

⇜Krishnan Mahadevan⇝

AFAIK, its not possible unless and until you are using the TestNG APIs and running tests via it instead of the usual surefire plugin.

 

But all said and done, why not have a listener dynamically build out your actual TestNG suite xml file itself based on what release you are working with ?

 

You could start off with implementing the interface org.testng.IAlterSuiteListener and within its alter() method depending upon the type of the release, you choose to add a new XmlSuite object or not.

 

I think that should work for you.

 

For more information you could take a look at this blog post of mine : https://rationaleemotions.wordpress.com/2017/09/29/building-dynamic-testng-suites/

 

 

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/

 

From: <[hidden email]> on behalf of Lan Xia <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, August 1, 2018 at 6:54 PM
To: testng-users <[hidden email]>
Subject: [testng-users] is it possible to reference non-existing file in testng.xml?

 

It seems testng.xml needs to be able to see the all test classes that are listed, even if we doesn't run those tests.

 

Our test material contains tests for different java releases in one repo. In following example, featureA_extra does not existing when testing our release1. 

 

 

<test name="testRelease1">

   <classes>

     <class name="org.test.featureA" />

     <class name="org.test.featureC" />

   </classes>

</test>

<test name="testRelease2">

   <classes>

     <class name="org.test.featureA_extra" /> <===== do not exist when testing release1

   </classes>

</test>

 

when run testRelease1 test, we got following error:

 

[TestNG] [ERROR]

Cannot find class in classpath: org.test.featureA_extra

Exception in thread "main" java.lang.NullPointerException

at org.testng.TestNG.getStatus(TestNG.java:211)

at org.testng.TestNG.main(TestNG.java:1324)

 

Is it possible to reference non-existing file in testng.xml? Is there a way to configure TestNG to skip verifying test classes in testng.xml, specially for test that we do not run? We would prefer to keep one testng.xml file and do not to want to create a dummy test file featureB.java when running test for release1.

 

Thanks,

     Lan

 

 

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.