Skip to content

Testing Overview

Pyramid de Testing en lg5-spring

lg5-spring implementa un Testing Pyramid completo con tres niveles de prueba:

         / \ 
        / AT \        1 test - Cucumber BDD
       /______\        Acceptance Tests
      /         \     ───────────────────────
     / ___________ \   4-8 tests - Integration Tests
    / /            \ \  ───────────────────────
   / /______________\ \  10-50 tests - Unit Tests
  /____________________\

Niveles de Testing

NivelFrameworkContenedoresEnfoque
Unit TestsJUnit 5 + MockitoNingunoLógica pura del dominio
Integration TestsJUnit 5 + TestcontainersPostgres, KafkaLógica + Infraestructura
Acceptance TestsCucumber 7 + TestcontainersPostgres, KafkaComportamiento E2E

Cuándo Usar Cada Nivel

Unit Tests

┌──────────────────────────────────────────────────────────┐
│  Cuándo usar Unit Tests                                   │
│                                                           │
│  ● Testing de AggregateRoots                             │
│  ● Testing de ValueObjects                               │
│  ● Testing de lógica de dominio pura                       │
│  ● Testing de mappers (MapStruct)                        │
│                                                           │
│  Ejemplo:                                               │
│    - BlankTest.java                                      │
│    - BlankDomainServiceTest.java                         │
│    - BlankDataAccessMapperTest.java                      │
└──────────────────────────────────────────────────────────┘

Integration Tests

┌──────────────────────────────────────────────────────────┐
│  Cuándo usar Integration Tests                           │
│                                                           │
│  ● Testing de Controllers REST                          │
│  ● Testing de Repositorios con TestContainers            │
│  ● Testing de Kafka Consumers                            │
│  ● Testing end-to-end con base de datos real           │
│                                                           │
│  Ejemplo:                                               │
│    - BlankCreatorIT.java                                 │
│    - BlankRepositoryIT.java                              │
│    - ReportAdapterIT.java                                │
└──────────────────────────────────────────────────────────┘

Acceptance Tests

┌──────────────────────────────────────────────────────────┐
│  Cuándo usar Acceptance Tests (BDD)                        │
│                                                           │
│  ● Testing comportamiento de negocio en inglés        │
│  ● Testing E2E completo (HTTP + DB + Kafka)             │
│  ● Testing con third-party systems                        │
│  ● Validación de Reglas de Negocio                        │
│                                                           │
│  Ejemplo:                                               │
│    - blank-service.feature                               │
│    - BlankAcceptanceTest.java                            │
│    - StepDefinitions.java                                │
└──────────────────────────────────────────────────────────┘

Frameworks Utilizados

FrameworkPropósitoVersión
JUnit JupiterUnit & Integration tests5.12.0-RC1
MockitoMocking de objetos5.15.2
CucumberBDD / Gherkin7.21.1
TestcontainersPostgres, Kafka, WireMock1.20.4
Rest-AssuredTesting de endpoints REST5.5.0
AwaitilityEsperas async para eventos4.2.2
AllureReportes visuales de tests7.2.0

Makefile Commands

ComandoDescripción
make all-buildConstruye todo
make run-ut-spec TEST_NAME=XUnit test por nombre
make run-it-spec TEST_NAME=XIntegration test por nombre
make run-at-spec TEST_NAME=XAcceptance test por nombre
make run-test-spec TEST_NAME=XCualquier test (lento)
make run-checkstyleValidación código

Released under the MIT License.