This is a sample Java application that demonstrates the use of various development tools and libraries:
- Gradle as build tool
- Checkstyle for code formatting
- SpotBugs for static code analysis
- JUnit 5 for testing
- Mockito for mocking
- AssertJ for fluent assertions
- JaCoCo for code coverage
- Lombok for reducing boilerplate code
- Java 17 or higher
- Gradle (wrapper is included)
To build the project, run:
./gradlew buildThis will:
- Compile the code
- Run the tests
- Generate test coverage reports
- Run Checkstyle
- Run SpotBugs
To run tests:
./gradlew testTo generate code coverage reports:
./gradlew jacocoTestReportThe reports will be available in:
- HTML:
build/reports/jacoco/test/html/index.html - XML:
build/reports/jacoco/test/jacocoTestReport.xml
To run Checkstyle:
./gradlew checkstyleMain checkstyleTest
# run the following for both main and test source set
./gradlew checkstyleAllThe report will be available in build/reports/checkstyle/
To run SpotBugs:
./gradlew spotbugsMain spotbugsTest
# run the following for both main and test source set
./gradlew spotbugsAllThe report will be available in build/reports/spotbugs/
src/main/java/- Source filessrc/test/java/- Test filesconfig/checkstyle/- Checkstyle configurationbuild.gradle- Gradle build configuration
The project includes a simple Calculator class that demonstrates:
- Lombok annotations (
@Data,@NoArgsConstructor,@AllArgsConstructor) - SpotBugs annotations
- Unit tests with JUnit 5
- Mockito spy
- AssertJ assertions