Spring Boot

Unit Testing with JUnit & Mockito

Unit testing with JUnit 5, Mockito for mocks, assertions, @Mock, @InjectMocks, test doubles

30 питань зі співбесід·
Mid-Level
1

What is JUnit 5 Jupiter?

Відповідь

JUnit 5 Jupiter is the modern testing engine that replaces JUnit 4, offering an improved API with modernized annotations and new features. Jupiter brings richer assertions, better support for parameterized tests, and a modular architecture allowing easy framework extension. Using Jupiter enables leveraging Java 8+ features like lambdas in assertions.

2

Which annotation marks a method as a test in JUnit 5?

Відповідь

The @Test annotation from JUnit 5 identifies a method as a test case that will be executed by the runner. Unlike JUnit 4 where @Test accepted parameters like expected or timeout, JUnit 5 uses dedicated assertions like assertThrows. Each @Test method should be autonomous and test a specific behavior in isolation.

3

What is the difference between @BeforeEach and @BeforeAll?

Відповідь

@BeforeEach runs before each test method to initialize a clean state, while @BeforeAll runs once before all tests in the class. @BeforeEach is ideal for creating fresh mocks or objects for each test, ensuring isolation. @BeforeAll requires a static method and is used for expensive initializations shared across all tests.

4

Which assertion verifies equality between two values?

5

How to verify that an exception is thrown in JUnit 5?

+27 питань зі співбесід

Інші теми співбесід Spring Boot

Spring Core - IoC & DI

Junior
22 запитань

Spring Boot Auto-Configuration

Junior
20 запитань

Spring Boot Starters

Junior
18 запитань

Application Properties & YAML

Junior
16 запитань

Logging with SLF4J & Logback

Junior
20 запитань

Spring Boot DevTools

Junior
15 запитань

Spring MVC Basics

Mid-Level
20 запитань

Spring REST Controllers

Mid-Level
20 запитань

Request & Response Handling

Mid-Level
20 запитань

Exception Handling

Mid-Level
25 запитань

Bean Validation

Mid-Level
25 запитань

Spring Data JPA Basics

Mid-Level
25 запитань

JPA Entities & Relationships

Mid-Level
30 запитань

JPA Queries

Mid-Level
30 запитань

Spring Data Repositories

Mid-Level
25 запитань

Spring Security Basics

Mid-Level
25 запитань

Spring Boot Actuator

Mid-Level
20 запитань

Spring Boot Testing

Mid-Level
30 запитань

Profiles & Environment

Mid-Level
20 запитань

RestTemplate & WebClient

Mid-Level
24 запитань

Async & Scheduling

Mid-Level
25 запитань

Caching with Spring

Mid-Level
25 запитань

Spring WebFlux (Reactive)

Mid-Level
25 запитань

Spring Transactions

Senior
30 запитань

Advanced Authentication & Authorization

Senior
30 запитань

JWT & Stateless Security

Senior
20 запитань

OAuth2 & Authorization Server

Senior
20 запитань

Spring Boot & Docker

Senior
19 запитань

Microservices with Spring

Senior
25 запитань

Spring Cloud Config

Senior
19 запитань

Performance Optimization

Senior
30 запитань

GraalVM Native Images

Senior
20 запитань

Опануй Spring Boot для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно