testng-team / testng-eclipse

Eclipse plug-in for TestNG
https://testng.org
193 stars 164 forks source link

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

Open tyrel opened 11 years ago

tyrel commented 11 years ago

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.

cbeust commented 11 years ago

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

tyrel commented 11 years ago

I do have "Build automatically" turned on.

tyrel commented 11 years ago

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 commented 11 years ago

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)

JnRouvignac commented 11 years ago

@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 commented 11 years ago

@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.

ChaitanyaBarsode commented 10 years ago

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

peacetrader commented 7 years ago

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