美文网首页
测试包路径错误异常

测试包路径错误异常

作者: 李小二的倔强 | 来源:发表于2018-11-01 10:31 被阅读0次

今天写了个测试类:由于测试类的包路径和代码包路径不一致,所以会报一下错误:

十月 31, 2018 4:20:42 下午 org.springframework.boot.test.context.SpringBootTestContextBootstrapper buildDefaultMergedContextConfiguration

信息: Neither @ContextConfiguration nor @ContextHierarchy found for test class [org.sdb.project.data.service.TransTest], using SpringBootContextLoader

十月 31, 2018 4:20:42 下午 org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations

信息: Could not detect default resource locations for test class [org.sdb.project.data.service.TransTest]: no resource found for suffixes {-context.xml, Context.groovy}.

十月 31, 2018 4:20:42 下午 org.springframework.test.context.support.AnnotationConfigContextLoaderUtils detectDefaultConfigurationClasses

信息: Could not detect default configuration classes for test class [org.sdb.project.data.service.TransTest]: TransTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.

java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

at org.springframework.util.Assert.state(Assert.java:73)

at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.getOrFindConfigurationClasses(SpringBootTestContextBootstrapper.java:243)

at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.processMergedContextConfiguration(SpringBootTestContextBootstrapper.java:155)

at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:395)

at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildDefaultMergedContextConfiguration(AbstractTestContextBootstrapper.java:312)

at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:265)

at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:108)

at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.buildTestContext(SpringBootTestContextBootstrapper.java:99)

at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:139)

at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:124)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:151)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:142)

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.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

解决问题: 更改测试的包路径,修改为和代码路劲一直即可。

相关文章

  • 测试包路径错误异常

    今天写了个测试类:由于测试类的包路径和代码包路径不一致,所以会报一下错误: 十月 31, 2018 4:20:42...

  • 02-pySpark Hello World

    编写测试文件 软件解压目录上层,新建测试文件 相关路径如下: 本地启动测试 可能遇到问题,路径异常 RDDs 特性...

  • 访问测试项目路径localhost:8080/hello 后台抛

    访问测试项目路径localhost:8080/hello 后台抛出异常:This application has ...

  • Flink用scala写出现Type mismatch

    1. 异常 IDEA提示错误: 2. 错误原因 StreamExecutionEnvironment导包错误。 用...

  • .NET如何处理异常

    try { throw new SystemException("测试错误!"); } catch { } 异常发...

  • doesn't declare an explicit app_

    导包问题,检查报错涉及到的导包路径,就是导包路径导致的错误参考:[https://cloud.tencent.co...

  • adb指令安装apk包报错:INSTALL_FAILED_TES

    错误描述 问题分析 此错误提示当前的apk包是测试包,所以需要添加额外的指令,使得当前的应用安装支持测试包。 使用...

  • Javascript 菜鸟 Structure

    ○○○ ○○○ 错误 try 和 catch:测试代码块 ○○○ Throw:抛出异常 exception ○...

  • Java基础10-异常

    概述 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的。异常发生的原因有很多,通常包...

  • 日志打印无堆栈信息

    情况:系统抛出异常,日志没有打印堆栈信息 错误日志正常打印 分析:异常信息打印格式没有错误,本地测试没有问题,线上...

网友评论

      本文标题:测试包路径错误异常

      本文链接:https://www.haomeiwen.com/subject/thvtxqtx.html