Presentation is loading. Please wait.

Presentation is loading. Please wait.

WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.

Similar presentations


Presentation on theme: "WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010."— Presentation transcript:

1 WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint They may not show up well on other PowerPoint versions. You can download PowerPoint 2010 viewer from here.here These slides contain a lot of animations. For optimal results, watch in slideshow mode. 20 min

2 Test inputExpected nullfalse Test inputExpected null,0exception While you wait for the lecture to start, design test cases for these two methods. When designing test cases, use heuristics covered in Lecture 9. /* Returns true if the name is non-empty and not null and not longer than 40 chars. */ public boolean isValidName(String name) { //... } /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); }

3 Test inputExpected nullfalse Test inputExpected null,0exception /* Returns true if the name is non-empty and not null and not longer than 40 chars. */ public boolean isValidName(String name) { //... } /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); }

4 Test inputExpected nullfalse Test inputExpected nullFalse “ ”False Length==41False Length==50False Length==40True Length==10True Equivalence partitions null empty Too long Right size Values null “ length = 41 40, 10, 50 /* Returns true if the name is non-empty and not null and not longer than 40 chars. */ public boolean isValidName(String name) { //... }

5 /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); } Test inputExpected nullFalse “ ”False Length==41False Length==50False Length==40True Length==10True null empty Too long Right size null “ Equivalence partitions Values length = 41 40, 10, 50

6 Eq. partitions invalid exists new Values Any invalid e.g. null Any existing name e.g. “existing guy” Any valid new name e.g. “new guy” name scoreany /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); } Test inputExpected “new guy”, 0success null, -3exception “existing guy”, 5exception

7 /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); } Integration tests are choreography tests. They do not test components. They test how well the assembly of components dance together. Test inputExpected nullFalse “ ”False Length==41False Length==50False Length==40True Length==10True Test inputExpected “new guy”, 0success null, -3exception “existing guy”, 5exception

8 Short and simple methods /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } storage.save(name, score); } Test inputExpected “new guy”, 0success null, -3exception “existing guy”, 5exception Do we really need these tests?

9 /* Throws StorageException if name is not valid or if name already exists in the database. */ public void saveScore(String name, int score) throws StorageException { if (!isValidName(name)) { throw new StorageException("invalid name"); } if (Storage.isFound(name)) { throw new StorageException("already exists"); } Storage.save(name, score); } Test inputExpected “new guy”, 0success null, -3exception “existing guy”, 5exception Do we really need these tests?

10 ..s bud 1: desc: send budget deadline: Thu 22 nd September 2: desc: review buddy program deadline: Wed 21 st September Where we are…

11

12

13 1. Aim to create a gem you will be proud to wear 2. Polish, check, polish, check, polish, check,… 3. Sharpen your tools once in a while

14 Today’s theme Nearing completion. Gearing up for bigger projects. ?

15 Estimate the statement coverage of this method for these three test cases. a) about 50% b) about 80% c) 100% cover {a|b|c} e.g. cover c cover {a|b|c} e.g. cover c Test inputExpected “new guy”, 0success null, -3exception “”, 5exception tinyurl.com/questionSMS


Download ppt "WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010."

Similar presentations


Ads by Google