2

I have a program that works as below for addition, and it's the same for all operations. It starts showing this menu:

Enter + for add
Enter - for subtract
Enter * for multiplicaiton
Enter ! for factorial

Enter the operation you want:

Here we can type an operation and click enter. For example if we type "+" we get:

 Enter the number of elements to add:

And we can choose any number, for example 2, to sum two elements. And the program asks:

  Please enter 2 numbers, one at a time:

We can type 5 and then click enter and then 5 again

   5 
   5 

And after click enter we get the result

   10

I'm trying to make a test suite for this program and I have some questions. For example I'm trying to do just for now a test suite for the addition operation described above, but I have some questions on how to do it.

For example, a first way, including all the steps until we get the result of sum "10":

Input                                  Output

 +                                    "Enter the number of elements to add:"

 2                                    "Enter 2 numbers one a at a time"

 5                                     5

 5                                     "Sum is = 10"

Or another way, considering just the addition part, not considering the menu part:

 Input                                   Output

   5                                       5
   5                                       10

Or, if it's not necessary to have in consideration the sequence of steps and we just consider the sum operation, like:

  Input                     Output

  5 + 5                      10

What is a good way to create the test suite for this addition operation above? Taking in consideration that the inputs and outputs can then be used in an automated way to check if each test case has passed or not.

2

I have a feeling this is your homework assignment. Emmmmmm...

It looks like your application is command line based; if you only want to test the addition function, there are a few options you can consider:

Ask yourself what you will expect from "addition"?

  • The simplest will be addition of positive integers
  • Addition of positive integers and zero
  • Addition of negative integers
  • Addition of positive integers and negative integers
  • Addition of negative integer and zero
  • Addition of multiple positive integers
  • Addition of multiple negative integers
  • Addition of multiple positive and negative integers
  • Addition of very large integers, you will fix up positive integers, negative integers and zero
  • Redo all tests described above with float point numbers
  • Redo all tests described above with mixed integer and float point numbers
  • Redo all tests described above with large float point numbers
  • Use your expectation to come up with more tests...

You can use a number generator routine to automate your tests.

  • Thanks for your answer. Im just trying to learn about testing. And I was trying with this example because the inputs and outputs are clear. But Im just in doubt in terms of what to test. If we need to cover all sequence of the program or because the main part of the program and the goal is a calculator we just test the calculator operations. – Ozzy Nov 22 '16 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.