亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

ABAP和Java SpringBoot的單元測(cè)試

fireflow / 433人閱讀

摘要:在類里,本地類里用關(guān)鍵字聲明過(guò)的方法,在單元測(cè)試啟動(dòng)后會(huì)自動(dòng)被調(diào)用到。在及的設(shè)定思路里,放在路徑下面以結(jié)尾的類會(huì)被當(dāng)成單元測(cè)試類處理。

ABAP

在ABAP類里,本地類(Local Class)里用關(guān)鍵字FOR TESTING聲明過(guò)的方法,

在單元測(cè)試啟動(dòng)后會(huì)自動(dòng)被調(diào)用到。

Spring Boot

在Spring及Spring Boot “Convention over configuration”的設(shè)定思路里,放在路徑src/test/java下面以Tests.java結(jié)尾的Java類會(huì)被當(dāng)成單元測(cè)試類處理。

對(duì)上述項(xiàng)目執(zhí)行命令行mvn clean install后,報(bào)錯(cuò)誤消息:

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:70)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.getOrFindConfigurationClasses(SpringBootTestContextBootstrapper.java:202)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.processMergedContextConfiguration(SpringBootTestContextBootstrapper.java:137)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:409)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildDefaultMergedContextConfiguration(AbstractTestContextBootstrapper.java:323)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:277)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:112)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.buildTestContext(SpringBootTestContextBootstrapper.java:82)
at org.springframework.test.context.TestContextManager.(TestContextManager.java:120)
at org.springframework.test.context.TestContextManager.(TestContextManager.java:105)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:152)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:143)
at org.springframework.test.context.junit4.SpringRunner.(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:422)
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.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

從調(diào)用棧能看出,Spring Boot單元測(cè)試框架試圖自動(dòng)找到一個(gè)被施加單元測(cè)試的Java類,但是失敗了,所以報(bào)了異常。

由于我這個(gè)SpringBoot項(xiàng)目的入口是com.sap.smartService.SmartServiceApplication, 因此我需要在單元測(cè)試啟動(dòng)類里指定這個(gè)入口類:
@SpringBootTest(classes = com.sap.smartService.SmartServiceApplication.class)

加上之后maven build成功:

要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/72002.html

相關(guān)文章

  • ABAPJava單元測(cè)試Unit Test

    摘要:?jiǎn)卧獪y(cè)試的執(zhí)行入口,是硬編碼在單元測(cè)試框架實(shí)現(xiàn)里的。待執(zhí)行的單元測(cè)試方法通過(guò)返回到一個(gè)內(nèi)表里,然后該內(nèi)表,依次執(zhí)行。最常用的是,可以方便地單獨(dú)觸發(fā)單元測(cè)試,或者把單元測(cè)試的執(zhí)行集成為的一個(gè)子步驟。 ABAP ABAP class單元測(cè)試的執(zhí)行入口,CLASS_SETUP, 是硬編碼在單元測(cè)試框架實(shí)現(xiàn)CL_AUNIT_TEST_CLASS里的。showImg(https://segmen...

    cgh1999520 評(píng)論0 收藏0
  • 不喜歡SAP GUI?那試試用Eclipse進(jìn)行ABAP開發(fā)吧

    摘要:比如的的個(gè)性化設(shè)置是這樣的,字體必須用程序猿專用的等寬開源字體,這樣顯得比較專業(yè)。我覺得網(wǎng)上流傳的程序猿和工具的鄙視鏈很無(wú)聊,與其有時(shí)間去鄙視別人,不如把這時(shí)間用來(lái)深入研究自己每天用的,進(jìn)一步提高自己?jiǎn)挝粫r(shí)間內(nèi)的工作效率。 Jerry和SAP成都研究院一些新同事聊天時(shí),談到ABAP和SAP GUI這個(gè)話題。很多新同事在加入SAP成都之前,是做Java和C++開發(fā)的,習(xí)慣了Eclipse...

    jkyin 評(píng)論0 收藏0
  • SpringBoot 實(shí)戰(zhàn) (二) | 第一個(gè) SpringBoot 工程詳解

    摘要:代碼如下可以看到中一共有個(gè)依賴,其中只有是我手動(dòng)加入的,用于單元測(cè)試。點(diǎn)擊項(xiàng)目啟動(dòng)按鈕,效果如下好的程序必須配備完善的單元測(cè)試。測(cè)試結(jié)果如下可以看到紅圈框住的地方,出現(xiàn)這個(gè)綠色標(biāo)志證明單元測(cè)試沒(méi)問(wèn)題。 微信公眾號(hào):一個(gè)優(yōu)秀的廢人如有問(wèn)題或建議,請(qǐng)后臺(tái)留言,我會(huì)盡力解決你的問(wèn)題。 前言 哎呦喂,按照以往的慣例今天周六我的安排應(yīng)該是待在家學(xué)學(xué)貓叫啥的。但是今年這種日子就可能一去不復(fù)返了,沒(méi)...

    GeekQiaQia 評(píng)論0 收藏0
  • SAP OData編程指南

    摘要:目前被廣泛用于和的眾多應(yīng)用中,以及和一些正在開發(fā)的新一代云產(chǎn)品中。年月時(shí),我和德國(guó)一位負(fù)責(zé)的同事就這個(gè)話題在半小時(shí)的電話會(huì)議里產(chǎn)生了爭(zhēng)執(zhí)。德國(guó)同事看了之后,同意了我的意見。和微信集成系列教程這個(gè)系列教程里,和微信的交互,使用了,使用了。 OData(Open Data Protocol)協(xié)議是一個(gè)開放的工業(yè)標(biāo)準(zhǔn),用于定義RESTFul API的設(shè)計(jì)和使用。我的文章標(biāo)題前加上SAP的前綴...

    X1nFLY 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<