Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 2710 Software Construction Project 1 – Implementation: Test Drivers Dr. Xiao Qin Auburn University

Similar presentations


Presentation on theme: "COMP 2710 Software Construction Project 1 – Implementation: Test Drivers Dr. Xiao Qin Auburn University"— Presentation transcript:

1 COMP 2710 Software Construction Project 1 – Implementation: Test Drivers Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin xqin@auburn.edu

2 Pitfalls No purpose. Only offer testing ideas. No expected input and output. Expected inputs are not specific. Expected outputs are not specific. 1-2

3 How not to design test drivers // test drivers below void test_menu(void) { } void test_hall(void) { } void test_setEncouter(void) { } void test_create_puzzle(void) { } 1-3 There is no design. These are the names of your test drivers.

4 How not to design test drivers //creates character with set amount of time, //intel, and money //checks that searchChange increases money and //decreses time void searchChangeTest(); 1-4 You’re the design of your test case must be specific.

5 Be specific: An Example 1-5

6 Can you test an abnormal usage? 1-6 void searchChangeTest() { Player player; cout << "Testing function searchChange()… "; player.intel = 10; player.time = 0; player.money = 10; searchChange(player); player.intel = 10; player.time = 10; player.money = 0; searchChange(player);... }

7 Exercise 1: Write a test driver for moveForward() u_short moveForward(Player&); /* * This function moves a player forward one step, * but risks an Encounter or a Puzzle. Moving * also takes 5 time units. * Input: A Player variable containing all of a * player's current game stats. * Output: 0 success * 1 can not move further * 2 negative money * 3 negative intel * 4 negative time */ 1-7

8 A test driver: moveForwardTest() void moveForwardTest(void) { Player testPlayer; /* Case 1: Enough money, intel, and time */ u_short errorStats; cout << “Test moveForwardTest() case 1:\n”; testPlayer.steps = 50; testPlayer.time = 1000; testPlayer.intel = 1000; testPlayer.money = 1000; error_stats = moveForward(testPlayer); assert(errorStats == 0); assert(testPlayer.steps == 51); assert(testPlayer.time == 995); } 1-8

9 A test driver: moveForwardTest() (cont.) /* Abnormal cases */ /* Case 2: Player can not move further */ cout << “Test moveForwardTest() case 2:\n”; testPlayer.steps = HALL_LEN; errorStats = moveForward(testPlayer); assert(errorStats == 1); /* Case 3: Player has negative time */ cout << “Test moveForwardTest() case 3:\n”; Player testPlayer.time = -10; errorStats = moveForward(testPlayer); assert(errorStats == 4);...... } 1-9

10 Exercise 2: Write a test driver for professor() u_short professor(Player&); /* * Encounter a professor. Player loses a random * extra amount of time, but may slightly increase * intelligence. * Input: A Player variable containing all of a * player's current game stats. * Output: 0 success * 2 negative money * 3 negative intel * 4 negative time */ 1-10


Download ppt "COMP 2710 Software Construction Project 1 – Implementation: Test Drivers Dr. Xiao Qin Auburn University"

Similar presentations


Ads by Google