Pages

Friday, October 25, 2013

Move the Robot Program


Fig 1 Move the Robot

 
1
2
3
4
1
Robot



2




3




4





Fig 2. Screen output when the program Move the Robot is executed. (For simplicity I have made a table to track the robot position.)


This is a sample program, named Move the Robot.

Move the Robot has two sub-modules, Move left and Move Right.


When left key is pressed on keyboard, the Robot invokes module Move left and moves one place to its left.

When right key is pressed on keyboard, the Robot invokes module Move right and moves one place to its right.
The main program Move the Robot calls Move left and Move right modules from within.
Initial position of the Robot is (1,1).

                                            Find us on facebook: facebook.com/softwaretestingbykunti


Module Testing / Unit Testing Concept

Please refer to Move the Robot figure and explanation here -http://softwaretestingbykunti.blogspot.com/2013/10/move-robot-program.html

I would suggest keep the Move the Robot page open while you read this.

How do I proceed with developing and testing this program?
·     Create a main module, Move the Robot. It will place the Robot in the position (1,1) on the screen and wait for Keyboard instruction to move the robot to left or right.
·     Test the main module, Move the Robot.
What can we test in the main module?
·         Test that the main module runs without giving severe errors or warnings.
·         Test that the main module when executed displays a screen with the Robot.
·         Test that the main module when displays a screen with Robot, has the Robot placed at position (1,1).

    What can we not test in the main module?
Even though we have written the code for waiting for Keyboard instructions in the main module, we cannot see any difference when any keys are pressed on the keyboard (except for exit).
This is because we have not told the main module what to do when any key is pressed on the keyboard.
We could write the code to call modules, Move left and Move right in the main module.
But remember we have not coded Move left and Move right modules yet.
Therefore, when we run the main module, Move the Robot. There are high chances that the program gives an error.

Move the Robot is a complex program with numerous instructions in it. There will be a team of people working on this program. A single person may not code all the three modules, namely Move the Robot, Move left and Move right.

Suppose modules are written in the following order:
1.     Main module, Move the Robot
2.     Move left
3.     Move right

Once when Main module, Move the Robot is finished coding, one want to test it rather than waiting for the Move left and Move right modules.
This would help remove errors that Move the Robot will contain and will also be easy to debug errors related to this module.

If in case all the three modules are written by 3 different people in parallel, then each one would want to test their module before all the 3 modules are tested together. Again, for the same reason that it would be easy to debug errors related to a specific module.
This will make it easier to test when all the 3 modules are integrated and tested. As possibly all specific module related testing would be over and their errors resolved.

Hope you understood this concept of testing! This is known as Module testing, where each module is tested before it is tested in a program. Module can be subroutine, subprograms, procedures of a program.

Advantage of Module testing:
·     Each module is tested and debugged before tested as a complete software.
·     The error debugging is easier.
·     Many modules can be tested simultaneously.

                  Find us on facebook: facebook.com/softwaretestingbykunti