1 / 17

Assignment: Unit Testing

Assignment: Unit Testing. Wall-follower applied to a simple maze. Perfect Maze. A perfect maze is defined as a maze which has one and only one path from any point in the maze to any other point no inaccessible sections no circular paths no open areas. “Pefect Maze”. xSxxxxxxxxxxxxxxxx

thai
Télécharger la présentation

Assignment: Unit Testing

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. Assignment: Unit Testing

  2. Wall-follower applied to a simple maze

  3. Perfect Maze A perfect maze is defined as a maze which has one and only one path from any point in the maze to any other point • no inaccessible sections • no circular paths • no open areas

  4. “Pefect Maze” xSxxxxxxxxxxxxxxxx x x x x x xx x xxx x xxx x x x x x x xx x xxxxxx xxxxxx xx x x x x x xx xxx x x xx x x xxx xxxx xxxx x x x x xxxxxxxxxxxxxxxxEx

  5. * Denotes a node xSxxxxxxxxxxxxxxxx X* x x x x xx x xxx x xxx x x x x x * x xx x xxxxxx xxxxxx xx x x x* x * x xx * xxx x x xx x x xxx *xxxx xxxx x x x * x XxxxxxxxxxxxxxxxEx

  6. S E

  7. “Pefect Maze” xSxxxxxxxxxxxxxxxx x x x x x xx x xxx x xxx x x xE x x x xx x xxxxxx xxxxxx xx x x x x x xx xxx x x xx x x xxx xxxx xxxx x x x x xxxxxxxxxxxxxxxxxx

  8. S E

  9. Pseudo-codein its simplest form InitPosition InitDirection done = FALSE; While (!done) if IsOpenForward { MoveForward if IsEndNode done = TRUE else if IsOpenToRight TurnRight } else TurnLeft;

  10. “Units” • Read a grid • Clean the grid • Find start position • Find start direction • Test forward cell • Test right cell • Test end of maze • Turn left • Turn right • Move forward • Record cell entering data • Direction • Report(s): • Cells visited • Count of visits to cell • Directions from which cell was entered

  11. For testing, try using: • ‘ ‘ will denote an open cell • ‘x’ will denote a wall • ‘s’ is start • ‘e’ is end • Make your application adaptable for these values

  12. Simple Moving and Direction • movements: • east: dx=1, dy=0 • south: dx=0, dy=-1 • west: dx=-1, dy=0 • north: dx=0, dy=1 • To turn, increment or decrement through directions

  13. Test Grid You don’t need an actual “maze” to test but you do need a grid. Example: xxxxx x123x x456x x789x Xxxxx By using these types of known inputs, it becomes easy to test your units. In this case, each non-wall cell has a unique value.

  14. Example Test Grid Cases • Edges not closed • Generate a warning • Not all chars in same case • No ‘end’ cell • No ‘start’ cell • ‘extra’ cells around maze

  15. Maze Assignment Full Reveal:Week 1 Feb 25 • BMP as input • This assignment is not about mazes • This assignment IS about unit testing and test-driven development • use Java or C# for the entire assignment • Purpose: use JUnit (or csUnit) • build indicated units • write tests for units • Points off for obvious cases that you did not consider

  16. Maze Assignment Full Reveal:Week 2 March 4 • Maze defined by BMP • solve mazes • Continue to use JUnit or csUnit • report non-perfect mazes • inaccessible sections • circular paths • open areas • report node locations • Employ A* • Report path and cost of path

  17. Maze Assignment Full Reveal:Week 3 March 11 • Create a GUI • test mazes • minimum: report problems • better: highlight offending part of maze, step through all problems detected • ideal: automatically repair problems when possible • edit mazes interactively • design mazes automatically

More Related