A test case is nothing but the inputs which are given to the program or software to test its capabilities and operations. Here our intention is to find if the software meets the specifications given by the customer. Test case should be derived effectively in order to find defects in the system.
Let’s discuss the process of deriving test cases for given program for both functional and structural testing.
Before identifying the test cases as a tester you should be through with functionality and the specifications of the software under test. And the test cases derived should test the system in terms identifying the defects. The test cases should be derived for the functions which the system should not work i.e negative test cases.
If A>B then
Print “A is greater”
Print “B is greater”
Now from the program we can identify that the function of the program is to find greatest of two numbers. Let’s try and find out the required test cases for the program.
With the known details the program will identify the greatest of two numbers and will produce any one of the results “A is greater” or “B is greater”. So the inputs which will make the program to give the result are A=10 and B=100 for “B is greater” and A=100 and B=10 for “A is greater”. Hence we have identified test cases for the actual or expected output.
Now let’s think this way, What if both I/P have same values? And what should the program do at this state? This type thinking is actually required for the testers to derive effective test cases. This method of identifying test cases that are opposite to the function is called negative cases or negative testing. In this case if both I/P are same the program is not coded to produce any error pop up or warning. Which means my application will crash or will not produce any result. Another possibility is that the I/P given can be any value apart from numbers, but this is extreme case and this can also happen.
Then summarizing the various Test cases in a template as follows,
The actual result column and Pass/Fail column has to be filled after completing the test process. For static test techniques the test cases cannot be derived as the program will not be executed. Test cases will be derived only for the blackbox and whitebox techniques. The number of test cases can be varied based on the requirements and amount of testing required.