Story points | 2 |
Tags | tdd |
Hard Prerequisites |
|
The objective of this project is to build a calulator that can perform multiplication and addition on multiple integers. Do not build a front-end (UI). Complete this project by using a TDD approach.
The basic TDD approach is as follows:
Remember to make sure your tests still pass after refactoring it.
Use Jasmine to test your code. Please do not use the SpecRunner html file to test your code. Run Jasmine on the terminal.
After setting up Jasmine on the terminal, please ensure that your directory has the following:
A src folder that has a file called:
A spec folder that has a file called:
Your directory structure should look like this:
>node_modules <---- make sure this is in your .gitignore
>spec
> support
- jasmine.json
- simple_calculator_spec.js
>src
- simple_calculator.js
- package.json
Your project is expected to be completed using pytest. You are expected to follow industry best practices in all things. This means that you need to have a directory structure that is in good shape. Please name your files and folders like this:
├── simple_calculator the package under test
│ └── calculator.py
├── requirements.txt installation requiremnts
├── setup.py installation script for the package under test
└── tests all package tests go in this directory
└── test_calculator.py
Please take a look at this topic to see an explanation of the required directory structure. : [TODO] Umuzi Tech Department
You’ll be using IntelliJ, Gradle and JUnit to pull this off.
Create a class named Calculator
. All your methods should be static methods that return integers. Eg:
public static int add(....
Please make sure that you make proper use of gitignore. We don’t want your junk files. The git repo you give us should have a file hierarchy that looks like this:
├── build.gradle
├── gradle
│  └── wrapper
│  ├── gradle-wrapper.jar
│  └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
├── main
│  └── java
│  └── Calculator.java <-------- names are important
└── test
└── java
└── CalculatorTest.java <-------- names are important
Please refer to the following to find out more: TOPICS: Gradle and IntelliJ project submission structure
Create a function called add
that works like this:
add(1,2)
// should return 3
add(-1,-1)
// should return -2
The add
function should now behave like this:
add(1,2,3,4,5)
// should return 15
add(1,2)
// should still return 3
add(-1,-1)
// should still return -2
Please note that your function should NOT expect an array or list of numbers, for example:
add([1,2,3,4])
This is NOT what we are looking for. If you have square brackets inside your round brackets, you are doing it wrong. The same will apply for the multiply function you will build in the next section.
Create a function called multiply
that works like this:
multiply(1,3)
// should return 3
multiply(-1,3)
// should return -3
The multiply
function should now behave like this:
mutilply(1,2,3,4,5)
// should return 120
multiply(1,3)
// should still return 3
multiply(-1,3)
// should still return -3