dyc87112 / SpringBoot-Learning

《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!
https://blog.didispace.com/spring-boot-learning-2x/
15.74k stars 4.88k forks source link

chapter2-5 测试好像有问题 #52

Open yansheng836 opened 4 years ago

yansheng836 commented 4 years ago

1.测试问题

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)改为@SpringBootTest好像就可以了。 see https://github.com/dyc87112/SpringBoot-Learning/blob/master/2.1.x/chapter2-5/src/test/java/com/didispace/chapter25/DemoApplicationTests.java#L17

2.maven install问题

[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.329 s <<< FAILURE! - in com.didispace.chapter25.DemoApplicationTests
[ERROR] generateAsciiDocs(com.didispace.chapter25.DemoApplicationTests)  Time elapsed: 0.736 s  <<< ERROR!
java.lang.NoClassDefFoundError: org/pegdown/PegDownProcessor
    at com.didispace.chapter25.DemoApplicationTests.generateAsciiDocs(DemoApplicationTests.java:35)
Caused by: java.lang.ClassNotFoundException: org.pegdown.PegDownProcessor
    at com.didispace.chapter25.DemoApplicationTests.generateAsciiDocs(DemoApplicationTests.java:35)

2020-08-01 11:35:18.228  INFO 9356 --- [       Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   DemoApplicationTests.generateAsciiDocs:35 » NoClassDefFound org/pegdown/PegDow...
[INFO] 
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.299 s
[INFO] Finished at: 2020-08-01T11:35:18+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project chapter2-5: There are test failures.
[ERROR] 
[ERROR] Please refer to G:\Workspaces\MyEclipse2017\SpringBoot-Learning\2.1.x\chapter2-5\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[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