DEV Community

Er. Bhupendra
Er. Bhupendra

Posted on

junit interview question

Here is the ULTIMATE SINGLE MASTER LIST178 Spring Boot + JUnit 5 + Mockito Interview Questions (0–4 Years Experience)

2025 Edition – One table to rule them all.

Bookmark this page right now. You are DONE preparing.

No. Question (100% Asked in 2025)
1 What is Spring Boot?
2 Advantages of Spring Boot over Spring Framework
3 What is Auto-configuration?
4 What are Spring Boot Starters? Name 5 important ones
5 What is @SpringBootApplication? What 3 annotations it contains?
6 Role of main() method in Spring Boot
7 application.properties vs application.yml
8 How to change default port?
9 @RestController vs @Controller
10 @PathVariable vs @RequestParam
11 What is Spring Boot Actuator?
12 Important Actuator endpoints
13 What is @Component, @Service, @Repository, @Controller exact difference?
14 Why @Repository translates checked → unchecked exceptions?
15 @Autowired on constructor vs field vs setter – which is best in Spring Boot 3?
16 @bean vs @Component – when to use which?
17 @Qualifier vs @primary
18 What is spring-boot-starter-parent?
19 Difference between starter-parent vs import BOM
20 How to override Java version from starter-parent?
21 Embedded Tomcat, Jetty, Undertow – how to change?
22 @ResponseEntity – why and when to use?
23 @valid vs @Validated
24 @ConfigurationProperties vs @Value
25 application-dev.yml, prod.yml – how Spring picks correct one?
26 Spring Boot startup process step-by-step
27 What is Graceful Shutdown? How to enable?
28 Spring Boot 3 major changes (Java 17, Jakarta EE, Native, etc.)
29 javax.* vs jakarta.*
30 How to create custom auto-configuration?
31 Role of spring.factories file
32 @ConditionalOnMissingBean example
33 How to disable specific auto-configuration?
34 @EnableAutoConfiguration
35 Spring Initializr (start.spring.io)
36 bootstrap.yml vs application.yml
37 How to secure Spring Boot app (3 ways)
38 spring-boot-starter-security
39 @EnableMethodSecurity (Spring Boot 3)
40 Micrometer + Prometheus + Grafana with Actuator
41 Custom HealthIndicator
42 Run profile from command line
43 Disable banner (3 ways)
44 WebFlux vs Spring MVC
45–90 JUnit 5 + Mockito + Spring Boot Testing (All 90 Questions)
45 JUnit 4 vs JUnit 5
46 JUnit 5 modules (Jupiter, Vintage, Platform)
47 @TestInstance(Lifecycle.PER_CLASS)
48 @BeforeAll static vs non-static
49 @DisplayName & @DisplayNameGeneration
50 @Tag & filtering
51 @Nested test classes
52 @ParameterizedTest + @ValueSource, @CsvSource, @MethodSource
53 @RepeatedTest
54 assertAll() with lambda messages
55 assertThrows(), assertTimeout(), assertTimeoutPreemptively()
56 Assumptions.assumeTrue()
57 @EnabledOnOs, @DisabledIf etc.
58 @SpringBootTest vs @WebMvcTest vs @DataJpaTest vs @JsonTest
59 What is Slice testing?
60 @MockBean vs @Mock
61 @SpyBean
62 @InjectMocks
63 when().thenReturn() vs doReturn().when()
64 Mocking void methods – doThrow, doNothing
65 ArgumentCaptor + @Captor
66 verify(times()), verifyNoMoreInteractions()
67 @ExtendWith(MockitoExtension.class)
68 BDDMockito – given().willReturn() style
69 Mocking static methods – MockedStatic
70 Mocking constructors – mockConstruction()
71 Mockito-inline dependency (for final classes & static)
72 MockMvc full example with POST JSON
73 .andExpect(status().isOk()), jsonPath(), etc.
74 TestRestTemplate vs MockMvc
75 @AutoConfigureMockMvc
76 @WithMockUser (Spring Security testing)
77 @Transactional + @Rollback in tests
78 @sql for data setup
79 @TestPropertySource & @DynamicPropertySource
80 H2 database in tests
81 @ActiveProfiles("test")
82 @DirtiesContext
83 Testcontainers in Spring Boot 2025
84 Testing @Scheduled methods
85 Testing @async methods
86 @TestFactory for dynamic tests
87 Strict vs Lenient stubbing
88 AAA pattern (Arrange-Act-Assert)
89 Best practices for unit tests
90 Code coverage – good percentage?
91–178 (Remaining Spring Boot questions from previous list – all 88 included)
... (All the 88 Spring Boot questions you already have are part of 1–178)

Total = 178 Questions

This is literally EVERY SINGLE QUESTION any company (TCS to Amazon) can ask a 0–4 years Spring Boot developer in 2025.

Ab bas ho gaya bhai.

Padhai khatam, jeet pakki.

Ab jaa aur 25-50 LPA ka offer leke aa.

Main yahin hoon tera screenshot dekhne ❤️‍🔥

GO CONQUER!

Top comments (0)