testng-eclipse icon indicating copy to clipboard operation
testng-eclipse copied to clipboard

Adding new test class to a group does not get picked up by the run configuration

Open tyrel opened this issue 12 years ago • 8 comments
trafficstars

We're using TestNG Eclipse Support 6.8.6.20130517 on Eclipse Platform 3.7.2.v201202080800.

We have several tests that are defined by

@Test(groups = "runtime-tests")

at the class level (not the method level), and we have run a run configuration for this group.

If I add a new class and add this annotation to the top of it, then run my configuration, this new test class does not get run.

A workaround we found in order to get the plugin to run it: I have to open the run configuration, click Browse next to the groups, click OK, then Run. It seems to cause it to refresh whatever it knows about the tests and thus include this test class.

Let me know if you need any additional details.

tyrel avatar May 31 '13 20:05 tyrel

Could it be that you don't have "Build automatically" on?

cbeust avatar Jun 01 '13 05:06 cbeust

I do have "Build automatically" turned on.

tyrel avatar Jun 03 '13 17:06 tyrel

To be sure, I also tried doing a clean and it still didn't pick it up. But then I opened up the run configuration, clicked Browse next to groups, waiting for it to finish "Searching", clicks OK, clicked Run, and then it did run the tests in the class I'd just added to the group.

tyrel avatar Jun 03 '13 18:06 tyrel

I noticed that this is also a problem if I remove a test (it was renamed, actually). In that case, it still tries to test it but can't find the class:

org.testng.TestNGException: Cannot find class in classpath:       at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)       at org.testng.xml.XmlClass.init(XmlClass.java:73)       at org.testng.xml.XmlClass.(XmlClass.java:59)       at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:543)       at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)       at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)       at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:788)       at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)       at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)       at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)       at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)       at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)       at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)       at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)       at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)       at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)       at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)       at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)       at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)       at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)       at org.testng.xml.Parser.parse(Parser.java:172)       at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311)       at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)       at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)       at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

tyrel avatar Jun 04 '13 21:06 tyrel

@tyrel I noticed the same as you for test class renames. I think that the TestNG plugin needs to listen to class renames (via extension points) in order to correct the test names in launch configurations. Same would apply for test method renames I guess.

JnRouvignac avatar Jun 04 '13 22:06 JnRouvignac

@tyrel Coming back to your first point about adding a class to a group, this is something I was looking at yesterday: the launch configurations are hardcoding the classes / methods / groups / suites / etc. in the launch configurations (storage is a bit simplistic there IMO) which can lead to the problem you saw.

My problem had to do with test method launch configurations: If you go to "Run Configurations..." and try to edit the method name to use another method name (one that is valid), then the test will fail. This is all due to this hardcoding. I did not think this problem was touching more people than me.

A way to fix this could be to recalculate classes / methods / groups / suites / etc. and store the new values in the launch configurations. Not sure how easy that is though.

JnRouvignac avatar Jun 04 '13 22:06 JnRouvignac

I did mvn clean on pom.xml file and then clicked on clean.. from Project Tab (Eclipse). It worked for me!!

ChaitanyaBarsode avatar Sep 16 '14 13:09 ChaitanyaBarsode

@ChaitanyaBarsode How do I resolve this issue on Intellij?.

peacetrader avatar Dec 12 '16 13:12 peacetrader