Problem with testng running of a single class / method
Hello everyone. I am running into a weird issue with running testng. Any time that I try to run a TestNG class, by right-click > Run, I get an error
Exception in thread "main" org.testng.TestNGException:
Test <test> element must define the name attribute
at org.testng.xml.TestNGContentHandler.xmlTest(TestNGContentHandler.java:225)
at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:443)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:767)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
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:107)
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.Parser.parse(Parser.java:162)
at org.testng.TestNG.setTestSuites(TestNG.java:507)
at org.testng.TestNG.configure(TestNG.java:946)
at org.testng.remote.RemoteTestNG.configure(RemoteTestNG.java:49)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:77)
Process finished with exit code 1
Indeed, if I look at the ~/Library/Caches/IntelliJIdea90/temp-testng-customsuite.xml it's missing the name attribute on the test tag:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Custom suite" parallel="none">
<test verbose="1" name="" annotations="JDK">
<classes>
<class name="xxx.xxx.xxx.xxx.ClassTest"/>
</classes>
</test>
</suite>
Any ideas ? I tried reinstalling Intellij, I deleted the caches folder, I restarted it, I deleted all the installed plugins.
Thank you,
Andrei Dragomir
请先登录再写评论。
Hello Andrei,
which versions of testng/IDEA do you use?
Thank you
-
Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Oh, it's Intellij 9.
Anyway, I fixed it, after a fashion. I searched more on the web, and I figured out that the test name is taken from the project name. For some reason, my project (maybe because it was imported from Eclipse projects) was defined by two files, but it didn't have a name; it was basically ".ipr", and ".iws". I simply renamed the ipr and iws file to actually have a name, and now it works.
So maybe the problem is that I had the project files without a name. I don't know exactly how this came to be, but maybe it's something one could look out for.
Thanks,
Andrei Dragomir
I've faced with similar problem:
Connected to the target VM, address: 'javadebug', transport: 'shared memory'
java.io.FileNotFoundException: C:\Users\�������\.IntelliJIdea90\system\temp-testng-customsuite.xml (Системе не удается найти указанный путь)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.testng.xml.Parser.<init>(Parser.java:68)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:338)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:91)
No test suite found. Nothing to run
Disconnected from the target VM, address: 'javadebug', transport: 'shared memory'
But problem in this case was UTF8 encoding. Switching project to Windows-1251 (System default) fixes problem.