Repository navigation
test(repositorio): adicionar testes de repositório com postgresql em container - #8
Merged
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



O que muda
Testes de repositório isolados com
@DataJpaTest, PostgreSQL 17 em Testcontainers (container estático por JVM) e Flyway real: 124 testes em 17 classes, só emsrc/test.BaseRepositorioTesteBancoDeTesteRepositoriofornecem a base e o container.join fetch, ordenação, filtros e restrições do banco (UNIQUE, inclusiveNULLS NOT DISTINCT, CHECK e FK, cada uma conferida pelo nome do constraint).Por que
Antes, nenhuma consulta JPA rodava fora do Cucumber, que executava 45 dos 59 métodos de repositório. Catorze não eram executados por nenhuma origem. Com estes testes, os 59 são executados.
A cobertura do JaCoCo quase não muda (linhas 99,7%, branches de 95,7% para 95,8%), porque o Cucumber já a saturava e interfaces não têm bytecode. O ganho é de verificação direta das consultas.
Pontos de atenção
src/main(três deIndicadorHistoricoRepositoryeRespostaOcupacaoRepository.existsByCampanhaId) e podem ser código morto.build.gradle, CI nemsrc/main, então não conflita com a branchci/jacoco-cobertura.Como testar
./gradlew testcom Docker aberto. A suíte completa tem 678 testes;OtoProjectApplicationTests.contextLoadssó passa com.envreal.