1 / 15

WARNING

WARNING. 20 min. These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010. They may not show up well on other PowerPoint versions . You can download PowerPoint 2010 viewer from here .

idalee
Download Presentation

WARNING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. While you wait for the lecture to start, design test cases for these two methods. • /* Returns true if the name is non-empty and • not null and not longer than 40 chars. */ • publicbooleanisValidName(String name) { • // ... • } • /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • Storage.save(name, score); • } When designing test cases, use heuristics covered in Lecture 9.

  3. /* Returns true if the name is non-empty and • not null and not longer than 40 chars. */ • publicbooleanisValidName(String name) { • // ... • } • /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • Storage.save(name, score); • }

  4. /* Returns true if the name is non-empty and not null and not longer than 40 chars. */ publicbooleanisValidName(String name) { // ... } Equivalence partitions Values null null empty “ “ , 50 Too long length = 41 Right size 40, 10

  5. /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • Storage.save(name, score); • } Equivalence partitions Values null null empty “ “ , 50 Too long length = 41 Right size 40, 10

  6. /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • Storage.save(name, score); • } Eq. partitions Values invalid Any invalid e.g. null exists Any existing name e.g. “existing guy” name new Any valid new name e.g. “new guy” score any any

  7. /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("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.

  8. /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • storage.save(name, score); • } Do we really need these tests? Short and simple methods

  9. /* Throws StorageException if name is not valid • or if name already exists in the database. */ • publicvoidsaveScore(String name, int score) • throwsStorageException { • if (!isValidName(name)) { • thrownewStorageException("invalid name"); • } • if (Storage.isFound(name)) { • thrownewStorageException("already exists"); • } • Storage.save(name, score); • } Do we really need these tests?

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

  11. 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

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

  13. Estimate the statement coverage of this method for these three test cases. • a) about 50% • b) about 80% • c) 100% 1 2 3 4 5 cover {a|b|c} e.g. cover c 77577 tinyurl.com/questionSMS

More Related