This project demonstrates a Java-based Calculator application with automated test cases using TestNG and Maven. It showcases Maven project structure, unit and integration testing, and code coverage reporting using the Surefire, Failsafe, and JaCoCo plugins. It showcases how to structure a Maven project, execute tests, and generate reports using the Maven Surefire Plugin.
- Java
- Maven
- TestNG
- Maven Plugins: Surefire, Failsafe, JaCoCo
- IntelliJ IDEA (IDE)
- Git & GitHub (version control)
- Basic calculator operations (Add, Subtract, Multiply, Divide)
- Automated test execution using TestNG
- Maven-based project structure
- Test execution using Maven lifecycle
- Unit test execution and HTML reports via Maven Surefire Plugin
- Integration test execution via Maven Failsafe Plugin
- Code coverage reports via JaCoCo Plugin
- Java 11+ installed
- Maven installed and configured
- Git (to clone the repo)
git clone https://github.com/AthiraThulasi/Calculator-TestNG-Maven.git
cd Calculator-TestNG-Mavenmvn clean testThis command:
- Removes old build files for a fresh start
- Compiles the project
- Runs TestNG unit tests
- Generates reports at
target/surefire-reports/
mvn clean verifyAfter the build, open:
target/site/jacoco/index.html
Test execution and coverage reports are generated by the configured Maven plugins.
Path: target/surefire-reports/
Includes:
- HTML report
- XML results
- Execution summary
Path: target/failsafe-reports/
Includes:
- HTML report
- XML results
- Integration test summary
Path: target/site/jacoco/
Includes:
index.html- interactive coverage report- Line, branch, and method coverage breakdowns
- Importance of standard Maven project structure for scalability and maintainability
- Maven lifecycle phases (validate → compile → test → package → install → deploy)
- Role of pom.xml as the central configuration file managing dependencies and build lifecycle
- Integration of TestNG with Maven for automated test execution
- How Maven Surefire Plugin executes TestNG tests and generates reports
- Difference between Surefire (unit tests) and Failsafe (integration tests), including the *IT.java naming convention and why Failsafe runs in the integration-test and verify phases
- How JaCoCo measures code coverage (line, branch, method) and how coverage reports help identify untested code paths
- Version control using Git and pushing code to GitHub using terminal commands
- Descriptive Test Naming — Test methods follow
methodName_condition_expectedResult(e.g.,add_TwoIntegers_returnSum) - No Loops in Test Cases — Each test validates a single scenario for simplicity and readability
- No Exception Handling in Tests — Exceptions fail tests naturally, surfacing real issues
- Avoid Code Duplication — Common objects are declared as instance variables rather than recreated per test
- No Input/Output Operations — Tests avoid external files or user input for reliability
This report shows the successful execution of TestNG test cases with all tests passing.
