# How to Write Test Cases for Calculator Application in Software Testing

**Table of Contents**hide

In this how-to, we will walk through how to write test cases for calculator in software testing. Many applications use calculations and calculator test cases can be a pretty common interview question. Some examples of applications include purchasing on eCommerce websites, calculating how much money is owed to a worker, and putting satellites into space. As a result, creating test cases for calculator in software testing applies to a fresher tester. Follow along with this how-to and finish your application’s first test case by creating your account in our free test case management tool. Before starting our test case, we need to define the Acceptance Criteria.

**What are the Acceptance Criteria for Scientific Calculator?**

As discussed in our requirements post, we must have functional requirements. So let’s go ahead and define them as such:

Description: “Taking Ubuntu Linux’s calculator must be able to perform basic mathematical calculations.”

Abbreviated Acceptance Criteria:

- Validate the calculator can add numbers.
- Validate the calculator can subtract numbers.
- Validate the calculator can multiply numbers.
- Validate the calculator can divide numbers.
- Validate any remaining arithmetic keys work.

**What are the functional test cases for calculator application?**

We will want to document several test cases related to a basic calculator. Typically test cases can be broken down into:

### Digital or Physical Calculator Scenarios:

- Validate all arithmetic operations (+, -, /, *, %, etc.) work properly.
- Verify the sum or equals key works properly.
- Verify all numbers work properly (0-9).
- Validate the bracket keys work.
- Verify the square and square root keys work.
- Ensure BODMAS / BIDMAS is applied when running complex queries and correct results are returned.
- Validate using decimal characters yields the correct result.
- Ensure spacing of all like buttons is equal.
- Validate the number of digits allowed in the calculator for an operation.
- Check the response value limit of the calculator.
- Ensure the memory functions work as expected.
- Validate previous calculations can be viewed.
- Verify the “C” or clear button cancels all digits and operations entered.
- Verify the back or delete button works when pressing the backspace key.
- Validate the latest operation overrides the prior one when two operations are pressed one after the other.
- Verify the addition of two integer numbers.
- Verify the addition of two negative numbers.
- Verify the addition of one positive and one negative number.
- Verify the subtraction of two integer numbers.
- Verify the subtraction of two negative numbers.
- Verify the subtraction of one negative and one positive number.
- Verify the multiplication of two integer numbers.
- Verify the multiplication of two negative numbers.
- Verify the multiplication of one negative and one positive number.
- Verify the division of two integer numbers.
- Verify the division of two negative numbers.
- Verify the division of one positive number and one integer number.
- Verify the division of a number by zero results in an error.
- Verify the division of a number by a negative number.
- Functionality test cases: check the division of zero by any number results in zero.

### Physical Simple Calculator only scenarios:

- Verify the calculator is a normal calculator and not a scientific calculator.
- Validate all buttons exist and the characters on them are legible.
- When using a solar-powered calculator, be sure batteries are not needed in full sunlight.
- When sunlight is unavailable for a solar-powered calculator, ensure battery operation works.
- Verify all of the buttons need a reasonable amount of pressure to operate.
- Validate the On and Off buttons work on the calculator.
- Verify the calculator’s outer shell is undamaged.
- Verify calculator time-out works as expected to turn the calculator off.
- Check the calculator’s state when pressing two buttons simultaneously.

### Software Based Calculator only scenarios:

- Validate help documentation can be accessed by going to Help -> Documentation.
- Verify the calculator accepts copy and paste functionality.

Keep in mind there are diminishing returns to testing, and developers should be using a thoroughly tested library. Here are some tests some folks might be tempted to run, but are not needed because they are using inbuilt operating system functionality not specific to the application.

- Verify calculator starts when the menu item is selected.
- Ensure the calculator can start by searching for the calculator.
- Validate the calculator window maximizes when pressing the appropriate button.
- Validate the calculator window minimizes when pressing the appropriate button.
- Validate the calculator closes when the close button is pressed or File->Exit option is selected.

The best thing you can do as a tester is discuss, with the developer, what the library code is doing and what it is not doing. Another quick sanity check is to review your developer’s code check-in for the story you are working on. Doing so can help target your testing efforts.

### Scientific Calculator and Programmable Calculator Test Cases:

Many folks, especially in school, have to use scientific calculators.

Here are some additional test scenarios for them:

- Validate the operation and results of the sin, cos, tan, and cos keys.
- Validate the operation and results of the x-1, x!,|x|,x^y, and f(x) keys.
- Validate the operation and results of the log key.
- Validate the operation and results of the logarithm key.
- Validate the operation and results of the factorial key.
- Validate the operation and results of the real and imaginary component keys.
- Validate the operation and results of the complex conjugate.
- If your advanced features calculator has converter options, each of the conversion function tests (angle, length, weight, area, volume, duration, currency, temperature) will need to be validated.
- If your advanced calculator has financial operations, each of the financial calculator tests (present value, future value, interest, time, etc.) will need to be validated.

## Writing T**est Cases for Calculator Application**

In this future section, we will go into detail on how to write the advanced tests calculator test cases. If you already have your free AccelaTest test management account and want to be added to this complete test case, please email us at bugbanishers@accelatest.com.

## Conclusion for Test Cases for Calculator in Software Testing

AccelaTest is a free test case management tool packed with features that most other testing tools charge a lot of money for. Get your free account now and create your test cases.