Skip to main content

Here is how to Run MockMvc in Spring boot

After you create your Spring boot project and when you write your first MockMvc test cases, you may land into the below error if the packages are not of same level.

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:76)

Solution:

Spring MVC boot application and the Test code should be in same package level

Below – Main application DemoApplication.java and HelloControllerTest.java should be in same package structure

com.rajesh.demo

Let me know if you still face issues.

Comments

Popular posts from this blog

Motivational Letter for Visa

 Motivational Letter for Visa To, The visa officer  XXXXXXXXXXXX From, XXXXX XXXXXXXXXXXXX Subject: Request for XXXX tourist Visa - Reg.   I am <YOU_NAME> holding Indian Passport ( No. <PASSPORT_NO>.  I would like to visit <PLACE> for a tourist vacation as a tourist along with my family, details given below. I have also enclosed my own financial papers, hotel bookings and flight ticket for your perusal. I will abide to the terms and conditions of the visa regulations and will return to my home country before my stipulated visa duration period. I am planning to travel on  < DATE MOTH YEAR> and return on <DATE MONTH YEAR > . The flight ticket and other travel expenses will be borne by me.    NAME DOB PASSPORT NO ISSUE DATE EXPIRY DAT...

South Korea Places to Visit

 South Korea Places to Visit Gyeongbokgung Palace National Folk Museum Myeong-dong Hanok village               Changdeokgung Palace      Seoul Tower - on Namsan Hill   Dongdaemun Night Market  Everland Theme Park  Gyeongju The Beomeosa Templ Busan Jeju Island  Shopping at Olive Young  Shopping at ART Box for kids    Seodaemun Prison History Museum  Street Market shopping