In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to conduct ABAP and Java SpringBoot unit testing, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
ABAP
In the ABAP class, the method declared with the keyword FOR TESTING in the local class (Local Class)
Is automatically called after the unit test starts.
Spring Boot
In the setting of Spring and Spring Boot "Convention over configuration", the Java class that ends with Tests.java under the path src/test/java is treated as a unit test class.
After executing the command line mvn clean install on the above items, an error message is reported:
Java.lang.IllegalStateException: Unable to find a @ SpringBootConfiguration you need to use @ ContextConfiguration or @ SpringBootTest (classes=...) With your testat 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 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)
As you can see from the call stack, the Spring Boot unit test framework attempts to automatically find a Java class to which the unit test is applied, but fails, so an exception is reported.
Since the entry for my SpringBoot project is com.sap.smartService.SmartServiceApplication, I need to specify this entry class in the unit test startup class:
@ SpringBootTest (classes = com.sap.smartService.SmartServiceApplication.class)
After that, maven build succeeded:
The above is how to carry out the unit test of ABAP and Java SpringBoot. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.