2

I'm learning about testing and having some doubts regarding test cases. For example, I was trying to create a test suite, a set of test cases for a calculator program.

The program is basically like below, are presented a set of operations and then we can choose an operation to sum two values or subtract or whatever.

Enter + for Sum
Enter - for Subtraction
Enter * for Multiplication
and so on..

So I was trying to write a test case for this program. What I read about test cases is that we have all the input options the program have and then the outputs, so it should be something like below?

Inputs                                   Outcome
 10 + 10                                  20
 20-10                                    10
30-50                                     -20
50*50                                    2500
50 * -1                                  -50
40/4                                      10
40/0                                      program stops
100 Mod 50                                0
200 Mod 30                                20
5!                                        120
-5!                                       only positives

Do you know if this is the correct way to write test cases? There are other options in test suites, but in this case, I'm just interested in the input and output parts but I don't know if it is like this that we write test cases in terms of input and output.

  • 50*50 = 500? Really, is that a typo or bug? – Yu Zhang Nov 20 '16 at 0:28
3

You have made a good start.

If you are only interested in inputs and outputs, then you need to consider the following:

Positive test cases, where you test scenarios that have valid inputs

  • You can use inputs that are well within the specifications of this calculator, and perform operations that are well defined within the specifications.

Negative test cases, where you test scenarios that have invalid inputs

  • Use inputs outside of specifications and introduce unexpected errors such as @$%^ as input or operators. The number of negative test cases is infinite; when you want to stop negative testing is up to the project timeline and resources.

  • With negative test cases, you may need to verify if this calculator can handle invalid input or operators graceful, that is it does not crash.

  • Thanks for your answer. For example if i put such symbols like $ the program dont crash but it stays blocked we can click on any button and the program dont do nothing. In this case the outcome of the test case when the input is "$" the outcome is what? – Ozzy Nov 20 '16 at 0:50
  • You need to refer to the specification for its outcome. – Yu Zhang Nov 20 '16 at 1:01
  • You mean see the code to check what happens when the input is different from the expected, like for example when the input is $? But if that verification is not in the code we what we shoud put in the output when the input is $ and the program just blocks with that input? – Ozzy Nov 20 '16 at 2:17
  • @Ozzy, if you have access to the source code, you can do it that way OR you can refer to the application specification documentation OR if there is no access to source code or documentation, you will use your expectation as if you were a customer, e.g. when you do something silly, the application should give you a warning message. – Yu Zhang Nov 20 '16 at 3:59
1

Yes, the Test Cases are always in the format Input(action) - Output(expected result).

Still your Test Cases need to have a subject title, then they need to consist of a number of steps and for each step you have input - output.

For example your first test case could be:

Test Case Name: Add 2 Numbers Step1: Type number 10 The number shows on the calculator's screen Step2: Press the + symbol The symbol shows on the calculator's screen Step3: Type number 10 The number shows on the calculator's screen Step4: Press the = symbol The number 20 shows on the calculator's screen

The point I am trying to make above is that each step of your test case should have a textual description for both the input and the output. Try to keep these descriptions brief and not too verbose.

Also, try to keep each action on the calculator as a separate test case.

  • Thanks for your answer. But in the example it is correct that part right? Each action in a separate test case? – Ozzy Nov 20 '16 at 0:52
  • You need a Test Case for addition, another Test Case for subtraction, another Test Case for multiplication etc. Your example does not look like a Test Case, it has everything together. – tasos Nov 20 '16 at 0:57

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.