TestNG tests do not compile when I do the & # 8594; clean

I use Spring, TestNG, Eclipse, Maven, Mac OS

Scenario

I make some changes in my test cases (TestNG test cases)

Then I do Project -> Clean in eclipse

Now I run the test file, but the changes are not updated.

I suspect the test files were not compiled.

I can start the server and I can start my web services

But if I run the maven test (mvn test), all the code compiles, including test cases.

So, to run the test cases, I only run the mvn test command.

Unable to launch eclipse.

Eclipse Configuration:

Auto build

In the way of building Java, a test suite is included

If you need more information I will provide you.

org.testng.TestNGException: Cannot find class in classpath: com.***.***.model.***.case.CaseModelImplTest at org.testng.xml.XmlClass.loadClass(XmlClass.java:76) at org.testng.xml.XmlClass.init(XmlClass.java:68) at org.testng.xml.XmlClass.<init>(XmlClass.java:54) at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:512) 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:2755) 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: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:170) at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:304) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:86) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170) 
+6
source share
9 answers

It seems you haven't included your test class in the build path. Right click on the Project folder, go to project properties-> src
include the testcase src folder by checking it.
Now it should work.

+4
source

Open the Problems view. In Eclipse, go to Window-> Show View-> Problems. It will list all crashes when compiling code.

+4
source

Are test cases compiled, but in the wrong directory? They should be compiled for test classes, and not for classes. In your build path you need to set the output folder

PROJECT / goal / test classes

This is true for all test resources (including src / test / java and src / test / resources).

Change the project properties in Eclipse, select the Java Build Path , and then on the Source tab you will see all the source directories. Each of them has an output folder. This output folder should be as above.

+3
source

Go to Project --> Clean

This worked for me with a similar problem.

+2
source

Please check your testNG.xml file for the correct test, because I received the same error, and this happened because the wrong test name was entered.

+1
source

Is your test folder added as the source folder in Eclipse? If this is not the case, it will not be included in the assembly.

0
source

I solved this:

  • Changing the build path / removing some of them
  • Project Cleanup
0
source

I think that for some time we get this error if your test class is in the default package and in Testng.xml, you specify below:

 <suite name="Suite" parallel="none"> <listeners> <listener class-name="org.uncommons.reportng.HTMLReporter" /> <listener class-name="org.uncommons.reportng.JUnitXMLReporter" /> </listeners> <test name="Test"> <classes> <class name=".Test1" /> </classes> </test> <!-- Test --> 

Here above, I moved my test class from the default package to some package, and also updated testng.xml as shown below - and it all started.

 <suite name="Suite" parallel="none"> <listeners> <listener class-name="org.uncommons.reportng.HTMLReporter" /> <listener class-name="org.uncommons.reportng.JUnitXMLReporter" /> </listeners> <test name="Test"> <classes> <class name="com.sigma.rest.api.Test1" /> </classes> </test> <!-- Test --> 

Hope this helps you ... if the problem still exists, try the options above.

thanks!

0
source

Verify that your project artifacts, such as excel, property files, xml files, etc., are open in text editors, etc. (if yes, please close them and rebuild)

When cleaning and restoring, make sure that all project-dependent files are closed and you create them.

0
source

Source: https://habr.com/ru/post/897214/


All Articles