測(cè)試包路徑錯(cuò)誤異常

今天寫了個(gè)測(cè)試類:由于測(cè)試類的包路徑和代碼包路徑不一致缎浇,所以會(huì)報(bào)一下錯(cuò)誤:

十月 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)

解決問(wèn)題: 更改測(cè)試的包路徑,修改為和代碼路勁一直即可赴肚。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末素跺,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子誉券,更是在濱河造成了極大的恐慌亡笑,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,546評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件横朋,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡百拓,警方通過(guò)查閱死者的電腦和手機(jī)琴锭,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,224評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門晰甚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人决帖,你說(shuō)我怎么就攤上這事厕九。” “怎么了地回?”我有些...
    開封第一講書人閱讀 164,911評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵扁远,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我刻像,道長(zhǎng)畅买,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,737評(píng)論 1 294
  • 正文 為了忘掉前任细睡,我火速辦了婚禮谷羞,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘溜徙。我一直安慰自己湃缎,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,753評(píng)論 6 392
  • 文/花漫 我一把揭開白布蠢壹。 她就那樣靜靜地躺著嗓违,像睡著了一般。 火紅的嫁衣襯著肌膚如雪图贸。 梳的紋絲不亂的頭發(fā)上蹂季,一...
    開封第一講書人閱讀 51,598評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音求妹,去河邊找鬼乏盐。 笑死,一個(gè)胖子當(dāng)著我的面吹牛制恍,可吹牛的內(nèi)容都是我干的父能。 我是一名探鬼主播,決...
    沈念sama閱讀 40,338評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼净神,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼何吝!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起鹃唯,我...
    開封第一講書人閱讀 39,249評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤爱榕,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后坡慌,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體黔酥,經(jīng)...
    沈念sama閱讀 45,696評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,888評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了跪者。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片棵帽。...
    茶點(diǎn)故事閱讀 40,013評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖渣玲,靈堂內(nèi)的尸體忽然破棺而出逗概,到底是詐尸還是另有隱情,我是刑警寧澤忘衍,帶...
    沈念sama閱讀 35,731評(píng)論 5 346
  • 正文 年R本政府宣布逾苫,位于F島的核電站,受9級(jí)特大地震影響枚钓,放射性物質(zhì)發(fā)生泄漏铅搓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,348評(píng)論 3 330
  • 文/蒙蒙 一秘噪、第九天 我趴在偏房一處隱蔽的房頂上張望狸吞。 院中可真熱鬧,春花似錦指煎、人聲如沸蹋偏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,929評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)威始。三九已至,卻和暖如春像街,著一層夾襖步出監(jiān)牢的瞬間黎棠,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,048評(píng)論 1 270
  • 我被黑心中介騙來(lái)泰國(guó)打工镰绎, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留脓斩,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,203評(píng)論 3 370
  • 正文 我出身青樓畴栖,卻偏偏與公主長(zhǎng)得像随静,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子吗讶,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,960評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容