以下内容是帮朋友解决的错误3,随后整理了遇到的其他几种
如果你没遇到过,可能需要花上一些时间。除了错误1
以下内容可能可以帮助你解决在执行maven test 中遇到的错误
错误1 在类路径找不到HTMLReporter 类 Listener org.uncommons.reportng.HTMLReporter was not found in project's classpath
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com:WEB_java08_05 >--------------------------
[INFO] Building WEB_java08_05 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ WEB_java08_05 ---
[INFO] Surefire report directory: C:\Users\Administrator\Desktop\WEB_java08_05\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
... 4 more
Caused by: org.testng.TestNGException:
Listener org.uncommons.reportng.HTMLReporter was not found in project's classpath
at org.testng.TestNG.initializeConfiguration(TestNG.java:907)
at org.testng.TestNG.run(TestNG.java:1031)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:93)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
... 9 more
[ERROR] There are test failures.
Please refer to C:\Users\Administrator\Desktop\WEB_java08_05\target\surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.118 s
[INFO] Finished at: 2019-01-28T15:27:41+08:00
[INFO] ------------------------------------------------------------------------
注意以上错误信息
[ERROR] There are test failures.
Listener org.uncommons.reportng.HTMLReporter was not found in project's classpath
报错原因,pom文件里面没有添加reportng依赖库
<!-- <dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version> < !--如果这里导入1.1.4版本就不会有第三个问题了,第三个问题是不讲道理的错误-->
<scope>test</scope>
</dependency> -->
错误2 解析xml错误
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 60; Document root element "suite", must match DOCTYPE root "null".
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com:WEB_java08_05 >--------------------------
[INFO] Building WEB_java08_05 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ WEB_java08_05 ---
[INFO] Surefire report directory: C:\Users\Administrator\Desktop\WEB_java08_05\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 60; Document root element "suite", must match DOCTYPE root "null".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
at org.testng.xml.Parser.parse(Parser.java:139)
at org.testng.TestNG.setTestSuites(TestNG.java:443)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:93)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
[ERROR]: No test suite found. Nothing to run
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.256 sec
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.186 s
[INFO] Finished at: 2019-01-28T15:36:03+08:00
[INFO] ------------------------------------------------------------------------
注意错误提示
[ERROR]: No test suite found. Nothing to run
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 60; Document root element "suite", must match DOCTYPE root "null".
执行套件里面少了以下内容
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
添加至执行套件内容中,摘取部分内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="suite" parallel="false" preserve-order="true">
错误3 没有任何错误提示,运行maven test命令只返回 运行:0失败0错误0
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com:WEB_java08_05 >--------------------------
[INFO] Building WEB_java08_05 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WEB_java08_05 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ WEB_java08_05 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ WEB_java08_05 ---
[INFO] Surefire report directory: C:\Users\Administrator\Desktop\WEB_java08_05\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.343 sec
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.104 s
[INFO] Finished at: 2019-01-28T15:38:52+08:00
[INFO] ------------------------------------------------------------------------
没有任何错误提示,运行maven test命令只返回 运行:0失败0错误0
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0,
关键字信息
There are no tests to run.
1.不管怎么运行,都没有test被执行
2.在尝试到删除掉reportng依赖及套件里监听器以及自定义的监听器,反复组合尝试,
运行maven test
结论:只要删除掉reportng依赖使用maven test就能成功执行用例
但是又不能不使用reportng
3.然后很快就找到解决方案
如果你遇到这种情况请检查你的reportng版本
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
<scope>test</scope>
</dependency>
错误4
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
给出一篇非常具有参考意义的帖子
https://blog.csdn.net/lslk9898/article/details/73836745
欢迎来到testingpai.com!
注册 关于