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/java
andsrc/test/java
); - Basic unit tests using
assertEquals
andassertNotEquals
; - Tests for business logic through service and DAO abstraction layers;
- Use of
Mock
implementations 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
: ContainsClientTest
and 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 forClient
testing;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 forContract
logic;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
ClientService
and corresponding unit tests with dependency injection and mock DAO use.
- Added
FilterByGenderTest
to check gender-based filtering accuracy; - Created
FilterByGender
andPerson
in thecoursetask
package with parsing logic; - Implemented
ClientTest
andTestClientTest
with basic structure and coverage; - Initialized the project with
FirstTest
and 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.