This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
software_carpentary2 [2011/06/20 03:50] medhamsh |
software_carpentary2 [2011/06/20 03:57] medhamsh |
||
---|---|---|---|
Line 53: | Line 53: | ||
===== Writing Tests ===== | ===== Writing Tests ===== | ||
- | * How to write tests so that: | + | How to write tests so that: |
- | o It's easy to add or change tests | + | * It's easy to add or change tests |
- | o It's easy to see what's been tested, and what hasn't | + | * It's easy to see what's been tested, and what hasn't |
- | * A test consists of a fixture, an action, and an expected result | + | |
+ | A test consists of a fixture, an action, and an expected result | ||
o A fixture is something that a test is run on | o A fixture is something that a test is run on | ||
o Can be as simple as a single value, or as complex as a networked database | o Can be as simple as a single value, or as complex as a networked database | ||
- | * Every test should be independent | + | Every test should be independent |
o I.e., the outcome of one test shouldn't depend on what happened in another test | o I.e., the outcome of one test shouldn't depend on what happened in another test | ||
o Otherwise, faults in early tests can distort the results of later ones | o Otherwise, faults in early tests can distort the results of later ones | ||
- | * So each test: | + | So each test: |
o Creates a fresh instance of the fixture | o Creates a fresh instance of the fixture | ||
o Performs the operation | o Performs the operation | ||
o Checks and records the result | o Checks and records the result | ||
+ | Find the exercises at http://software-carpentry.org/3_0/qa.html | ||
+ | |||
+ | ====== Reading Code ====== | ||
+ | |||
+ | Read the following code and test! | ||
+ | |||
+ | <code> | ||
+ | void main() | ||
+ | { | ||
+ | char str[40]; | ||
+ | int i,flag=0,len; | ||
+ | clrscr(); | ||
+ | printf("\n Enter A string : "); | ||
+ | gets(str); | ||
+ | len=strlen(str); | ||
+ | for(i=0;i<(len/2);i++) | ||
+ | { | ||
+ | if(str[i]!=str[len-1-i]) | ||
+ | { | ||
+ | flag=1; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | if(flag==1) | ||
+ | { | ||
+ | printf(" \n The string is not palindrome"); | ||
+ | } | ||
+ | if(flag==0) | ||
+ | printf("\n String is palindrome"); | ||
+ | getch(); | ||
+ | } | ||
+ | </code> | ||