0

全部。
我需要使用 VSCode 来制作项目。而且我不擅长用 VSCode 制作 java 项目。
我尝试使用带有 gradle 的 spring boot 来制作多项目。(图片:项目大纲)
告诉我我需要做什么来解决问题,我会立即附上评论。
当我运行 java 测试时,initializationError 发生如下:

initializationError Failed 0s
Message: N/A
Stack trace:
java.lang.Exception: No runnable methods
    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137)
    at org.springframework.test.context.junit4.SpringRunner.<init>(SpringRunner.java:49)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
4

1 回答 1

0

我有一个类似的问题,但有一个 Scala 项目。运行gradle buildgradle test失败很惨,但是当我按名称明确指定测试时,测试运行完成。

带有测试名称

$ gradle test --tests xxx.MyTest

BUILD SUCCESSFUL in 13s
3 actionable tasks: 1 executed, 2 up-to-date

没有测试名称

$ gradle test 

> Task :test

xxx.UnitSpec > initializationError FAILED
    java.lang.Exception at BlockJUnit4ClassRunner.java:191

xxx.SparkSessionTestWrapper > initializationError FAILED
    java.lang.Exception at BlockJUnit4ClassRunner.java:158

xxx.SparkSessionTestWrapper > initializationError FAILED
    java.lang.Exception at BlockJUnit4ClassRunner.java:191

xxx.SparkSessionTestWrapper$class > initializationError FAILED
    java.lang.Exception at BlockJUnit4ClassRunner.java:158

xxx.SparkSessionTestWrapper$class > initializationError FAILED
    java.lang.Exception at BlockJUnit4ClassRunner.java:191

7 tests completed, 5 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/xyz/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 12s
3 actionable tasks: 1 executed, 2 up-to-date
于 2020-11-25T20:21:15.927 回答