Basics Flashcards

(4 cards)

1
Q

Spring Boot Support for Unit Testing

A

Spring Boot provides test infrastructure so you can choose how much of the framework to load:
Pure Unit Test - No Spring context - Fast, isolated, uses mocks
@WebMvcTest - Only web layer -Controller logic with mocked services
@DataJpaTest - Only JPA layer- Repository logic with in-memory DB
@SpringBootTest - Full application context - Integration test (not unit!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Tatooable - For unit testing, you don’t use @SpringBootTest.

A

Instead, you use JUnit 5 + Mockito with plain Java testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Conceptual Flow - Arrange - Act - Assert

A

Setup (Arrange):
Create a PaymentService instance.
Inject a mocked PaymentRepository.
Tell the mock what to return when called.
Execute (Act):
Call paymentService.processPayment(orderId).
Verify (Assert):
Check that the method returns the expected result.
Verify that the repository was called once with the correct argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly