maven项目test报错Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin

时间:2021-05-28 19:11:22

今天导入一个原来的maven项目,项目上右键运行JUnit Test,可以通过测试,但是运行mvn test时,报错:
Results :

Failed tests: twm.camera.core.OutPutStringTest.testPrint(): org/junit/Assert

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0

[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 2.729 s
[INFO] Finished at: 2017-09-17T09:54:47+08:00
[INFO] Final Memory: 7M/19M
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project firstexm: There are test failures.
[ERROR]
[ERROR] Please refer to D:\workspace\mars\core\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

查阅了一下很早之前的资料,发现将测试类public class OutPutStringTest改为抽像类public abstract class OutPutStringTest后,去行mvn test即可通过。
没花时间去深究这类应用问题,谨此记录一下。有知道原因的可以留言。