/java-calculator-exercise

An exercise project to practice writing JUnit 5 tests.

Primary LanguageJavaMIT LicenseMIT

The Calculator

Java Language JVM Platform JUnit5 Testing Framework Maven Dependency Manager

A simple project to practice writing JUnit 5 tests.

This short guide describes:

Prerequisites

This starter project uses the Java programming language.

Before getting started, ensure you have Java 17 LTS (or higher) installed locally. The following commands should output the version of Java installed.

$ javac -version

javac 17.0.4
$ java -version

openjdk version "17.0.4" 2022-07-19 LTS
OpenJDK Runtime Environment Zulu17.36+13-CA (build 17.0.4+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.36+13-CA (build 17.0.4+8-LTS, mixed mode, sharing)

Development Setup

Clone this repository locally, then create a branch to work on.

git clone git@github.com:CodingBlackFemales/the-calculator.git
cd the-calculator
git checkout -b ${your-branch-name}

Install dependencies

Next, install the project dependencies and validate your project by running the following command at the root of your project:

./mvnw clean validate

If you are on a Windows machine, that will be:

mvnw clean validate

You should see the following console output:

$ ./mvnw clean validate

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------< com.codingblackfemales:the-calculator >-----------------
[INFO] Building the-calculator 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ the-calculator ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.155 s
[INFO] Finished at: 2022-11-03T20:56:09Z
[INFO] ------------------------------------------------------------------------

Practice

Exercise 1

Write tests to ensure the Calculator can multiply two numbers.
Think of all possible scenarios, and write a test for each of the scenarios.

Exercise 2

Write tests to ensure the Calculator can divide two numbers.
Think of all possible scenarios, and write a test for each of the scenarios.
One of the scenarios should encover a flaw in the Calculator implementation.

Exercise 3

Add more scenarios to cover the Calculator’s addition and subtraction functionalities.

Enjoy working on your exercise! 😃