In: Computer Science
1) List the three steps of test driven development and explain,
in detail, why these three steps are used.
2) Explain why the order of the steps is so
important.
3) For each of the following data types, explain what boundaries might be relevant to testing. Also, explain what values you would consider testing for parameters of this type. Justfiy your answers.
PART-1
1. Three steps of test driven development
A.Red, B.Green ,C.
Refactor
RED PHASE:-Create a test and make it fail
1.So basically the first step of this Red phase is to write unit test or any kind of test for our function and make sure that the test is short and simple, no much of complexity is required at this stage.
2.The second step is to increase the no. of lines in your code and write enough code so that it compiles.
3.Then, the third step is to Run the test and it should fail. By doing this you are basically making sure that the code your test is calling is the correct code.
GREEN PHASE:- Mandatory to pass the test using any method
1In this phase the first step is to write the code such that the test passes.
2 If the test passes then stop here, don't unnecessary increase your code lines.
3 Run the test again and watch it. Also this will result in green progress bar.
REFACTOR PHASE:-
1.Now is the time to remove unnecesary lines of code and keep the code more clean and efficient
2. If necessary make the design changes.
3. After each refactoring, rerun all the tests just to ensure that they all pass.
NOW, let us understand why do we use these steps:-
1. To improve the code quality
2.To improve application quality
3. To increase the developer's productivity
4.To help increase the scope of test coverage that is a higher test
coverage
------------------------------------------------------------------------------------------------------------------------------------------------PART-2
The order of these steps is must as it is a very thoughtful strategy to follow these steps. Follwing them would ensure that you write the test cases for the code and you are also writing only that much of a code which you need to test.To some of us this might not make sense but adding extra unnecessary lines of code is not needed and unused and writing more lines but inefficient code just wastes our resources. Better is to write minimal and efficient lines.
---------------------------------------------------------------------------------------------------------------------------------------------------
PART-3
1.Boolean:-
1.It is one of the simplest data type so it should be checked for values like false or true OR '0' and '1' depending on the language. For some langauages checking true or 1 are same but as I mentioned this is completely language specific.
2.Int:-
1.The range of integer varies depending on language which your code is in so just check that range.
2.Make sure to test positive and negative integers separate.
3.Check the data type carefully and that it is not double or float.
3.String:-
1.So most important is white spaces in strings, be very careful
handling them.
2.Make sure to be familiar with the use and limitation of strings
in that language.
for eg:- for some files string ='abc' and "abc" are same but in some langauges this isn't the case.
4. List:-
1.Remove an Element from a List Inside a loop. Make sure you don't make this basic mistake.
2.It's always better to know the length of list in start.
3.Learn to wisely use hastables and hashmaps. As there is a difference in them.
6.Point:-
1.These are meant to represent a point on a two dimensional plane, so just check for the size of the matrix which is acceptable according to the code.
2.Make sure you check correctly for Row and Column limitation.
3.A bigger matrix could be troublesome.
7. Optional
1.Make sure you don't store a null object.
2.This data type is specific to the java version so check that.
8.Map:-
1. Check if duplicates are allowed in the type of map you are using because this might lead to an exception.
---------------------------------------------------------------------------------------------------------------------------------------------------