一键导入
spring-tdd-mockito
// TDD (Test-Driven Development) skill with Mockito for Spring Boot. Guides the Red-Green-Refactor cycle for writing tests first.
// TDD (Test-Driven Development) skill with Mockito for Spring Boot. Guides the Red-Green-Refactor cycle for writing tests first.
| name | spring-tdd-mockito |
| version | 1.0.0 |
| description | TDD (Test-Driven Development) skill with Mockito for Spring Boot. Guides the Red-Green-Refactor cycle for writing tests first. |
| triggers | ["write test","tdd","mockito","unit test","test first"] |
┌─────────────────────────────────────────────────────────────┐
│ TDD WORKFLOW │
│ │
│ ┌───────┐ ┌───────┐ ┌──────────┐ │
│ │ RED │ ───→ │ GREEN │ ───→ │ REFACTOR │ ───┐ │
│ │ │ │ │ │ │ │ │
│ │ Write │ │ Write │ │ Improve │ │ │
│ │ Test │ │ Code │ │ Code │ │ │
│ └───────┘ └───────┘ └──────────┘ │ │
│ ↑ │ │
│ └──────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
| Annotation | Purpose |
|---|---|
@Mock | Create mock object |
@InjectMocks | Inject mocks into class under test |
@Spy | Partial mock - real methods + mock behavior |
@Captor | Capture arguments passed to mock |
@MockBean | Mock bean in Spring context |
@ExtendWith(MockitoExtension.class)
class ServiceTest {
@Mock
private Repository repository;
@InjectMocks
private Service service;
@Test
@DisplayName("Should do something when condition is met")
void shouldDoSomethingWhenConditionIsMet() {
// Given (Arrange)
when(repository.findById(1L)).thenReturn(Optional.of(entity));
// When (Act)
var result = service.doSomething(1L);
// Then (Assert)
assertThat(result).isNotNull();
verify(repository).findById(1L);
}
}
@DisplayNameComplete Java Spring Boot skill set for building enterprise applications. Includes modular architecture with optional components: - PostgreSQL database with JPA/Hibernate + Flyway migration - Redis caching (optional) - Kafka/RabbitMQ messaging (optional, choose one) - JWT + OAuth2 authentication (optional OAuth2) - RBAC authorization (optional) - TDD with Mockito - Spec-First Development with OpenSpec
Maven Modular Architecture with profiles for optional components. Enable/disable modules like Redis, Kafka, RabbitMQ dynamically.
Spec-First Development with OpenSpec for Spring Boot. Align on specifications before implementation begins.