Repository focused on the study and practice of Java unit testing using the JUnit 5 framework.
Includes practical examples of assertions, layered architecture with services and DAOs, and integration with code coverage tools like EclEmma.
Made using Spring Tools Suite 4.
- Project structure for unit testing (
src/main/javaandsrc/test/java); - Basic unit tests using
assertEqualsandassertNotEquals; - Tests for business logic through service and DAO abstraction layers;
- Use of
Mockimplementations to simulate success and failure scenarios; - Filtering logic validation through unit tests (
FilterByGenderTest); - Code coverage analysis using EclEmma plugin (Eclipse);
- Javadoc and inline comments included for clarity.
br.com.eaugusto: ContainsClientTestand its unit testTestClientTest;br.com.eaugusto.coursetask: ContainsPerson,FilterByGender, and related tests;br.com.eaugusto.mocks.dao/service: DAO and service layer interfaces and mock implementations forClienttesting;br.com.eaugusto.mockstests.service: Unit tests for client service behavior (success/failure);br.com.eaugusto.contract.dao/service: Interface definitions and mock/realistic DAO implementations forContractlogic;br.com.eaugusto.contracttests: ContainsContractServiceTest, testing all contract-related functionality.
- Clone this repository;
- Import into an IDE that supports JUnit 5 (e.g., Eclipse with EclEmma, IntelliJ);
- Run test classes (e.g.,
FirstTest,TestClientTest,ClientServiceTest,ContractServiceTest); - Use EclEmma to verify test coverage and validate implementation.
- Added search, delete, and edit methods to
ContractService, with full unit test coverage. - Created service and DAO layers for
Contract, including mock and exception-based implementations. - Developed
ClientServiceand corresponding unit tests with dependency injection and mock DAO use.
- Added
FilterByGenderTestto check gender-based filtering accuracy; - Created
FilterByGenderandPersonin thecoursetaskpackage with parsing logic; - Implemented
ClientTestandTestClientTestwith basic structure and coverage; - Initialized the project with
FirstTestand integrated JUnit 5 and EclEmma.
- Understand and structure Java projects with unit testing and test source folders;
- Learn to write assertions using JUnit 5 and analyze code behavior through testing;
- Practice service and DAO patterns with mock implementations and exception handling;
- Use test coverage tools to ensure testing effectiveness and code reliability.