17
Assignment: Unit Assignment: Unit Testing Testing

Assignment: Unit Testing

  • Upload
    thai

  • View
    84

  • Download
    4

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Assignment: Unit Testing

Assignment: Unit Assignment: Unit TestingTesting

Page 2: Assignment: Unit Testing

Wall-follower applied to a simple Wall-follower applied to a simple mazemaze

Page 3: Assignment: Unit Testing

Perfect MazePerfect Maze

A perfect maze is defined as a maze A perfect maze is defined as a maze which has one and only one path from which has one and only one path from any point in the maze to any other any point in the maze to any other pointpoint no inaccessible sectionsno inaccessible sections no circular pathsno circular paths no open areasno open areas

Page 4: Assignment: Unit Testing

““Pefect Maze”Pefect Maze”

xSxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxx x x xx x x xx xx x xxx x xxx xx xx x xxx x xxx xx x x x x xxx x x x x xxx xxxxxx xxxxxx xxx xxxxxx xxxxxx xxx x x x xx x x x xxx xxx x x xx xxx xxx x x xx xx xxx xxxx xxxxx xxx xxxx xxxxx x x xx x x xxxxxxxxxxxxxxxxxExxxxxxxxxxxxxxxxxEx

Page 5: Assignment: Unit Testing

* Denotes a node* Denotes a node

xSxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxX* x x xX* x x xx xx x xxx x xxx xx xx x xxx x xxx xx x x x * x xxx x x x * x xxx xxxxxx xxxxxx xxx xxxxxx xxxxxx xxx x x* x * xx x x* x * xxx * xxx x x xx xxx * xxx x x xx xx xxx *xxxx xxxxx xxx *xxxx xxxxx x x * xx x x * xXxxxxxxxxxxxxxxxExXxxxxxxxxxxxxxxxEx

Page 6: Assignment: Unit Testing

E

S

Page 7: Assignment: Unit Testing

““Pefect Maze”Pefect Maze”

xSxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxx x x xx x x xx xx x xxx x xxx xx xx x xxx x xxx xx xE x x x xxx xE x x x xxx xxxxxx xxxxxx xxx xxxxxx xxxxxx xxx x x x xx x x x xxx xxx x x xx xxx xxx x x xx xx xxx xxxx xxxxx xxx xxxx xxxxx x x xx x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Page 8: Assignment: Unit Testing

E

S

Page 9: Assignment: Unit Testing

Pseudo-codePseudo-codein its simplest formin its simplest form

InitPositionInitPositionInitDirectionInitDirectiondone = FALSE;done = FALSE;While (!done)While (!done) if IsOpenForwardif IsOpenForward {{ MoveForwardMoveForward if IsEndNodeif IsEndNode done = TRUEdone = TRUE else if IsOpenToRightelse if IsOpenToRight TurnRightTurnRight }} elseelse TurnLeft;TurnLeft;

Page 10: Assignment: Unit Testing

““Units”Units”► Read a gridRead a grid► Clean the gridClean the grid► Find start positionFind start position► Find start directionFind start direction► Test forward cellTest forward cell► Test right cellTest right cell► Test end of mazeTest end of maze► Turn leftTurn left► Turn rightTurn right► Move forwardMove forward► Record cell entering dataRecord cell entering data

DirectionDirection► Report(s):Report(s):

Cells visitedCells visited Count of visits to cellCount of visits to cell Directions from which cell was enteredDirections from which cell was entered

Page 11: Assignment: Unit Testing

For testing, try using:For testing, try using:

► ‘ ‘ ‘ ‘ will denote an open cellwill denote an open cell► ‘‘x’ will denote a wallx’ will denote a wall► ‘‘s’ is starts’ is start► ‘‘e’ is ende’ is end

►Make your application adaptable for Make your application adaptable for these valuesthese values

Page 12: Assignment: Unit Testing

Simple Moving and DirectionSimple Moving and Direction

►movements:movements:► east: dx=1, dy=0east: dx=1, dy=0► south: dx=0, dy=-1south: dx=0, dy=-1► west: dx=-1, dy=0west: dx=-1, dy=0► north: dx=0, dy=1north: dx=0, dy=1

►To turn, increment or decrement To turn, increment or decrement through directionsthrough directions

Page 13: Assignment: Unit Testing

Test GridTest Grid

You don’t need an actual “maze” to test but you You don’t need an actual “maze” to test but you do need a grid.do need a grid.

Example:Example:xxxxxxxxxxx123xx123xx456xx456xx789xx789xXxxxxXxxxx

By using these types of known inputs, it becomes By using these types of known inputs, it becomes easy to test your units. In this case, each non-easy to test your units. In this case, each non-wall cell has a unique value.wall cell has a unique value.

Page 14: Assignment: Unit Testing

Example Test Grid CasesExample Test Grid Cases

►Edges not closedEdges not closed Generate a warningGenerate a warning

►Not all chars in same caseNot all chars in same case►No ‘end’ cellNo ‘end’ cell►No ‘start’ cellNo ‘start’ cell► ‘‘extra’ cells around mazeextra’ cells around maze

Page 15: Assignment: Unit Testing

Maze Assignment Full Reveal:Maze Assignment Full Reveal:Week 1Week 1

Feb 25Feb 25►BMP as inputBMP as input►This assignment is not about mazesThis assignment is not about mazes►This assignment IS about unit testing and This assignment IS about unit testing and

test-driven developmenttest-driven development►use Java or C# for the entire assignmentuse Java or C# for the entire assignment

Purpose: use JUnit (or csUnit)Purpose: use JUnit (or csUnit) build indicated unitsbuild indicated units write tests for unitswrite tests for units

►Points off for obvious cases that you did not considerPoints off for obvious cases that you did not consider

Page 16: Assignment: Unit Testing

Maze Assignment Full Reveal:Maze Assignment Full Reveal:Week 2Week 2

March 4March 4► Maze defined by BMPMaze defined by BMP► solve mazessolve mazes► Continue to use JUnit or csUnitContinue to use JUnit or csUnit► report non-perfect mazesreport non-perfect mazes

inaccessible sectionsinaccessible sections circular pathscircular paths open areasopen areas

► report node locationsreport node locations► Employ A*Employ A*► Report path and cost of pathReport path and cost of path

Page 17: Assignment: Unit Testing

Maze Assignment Full Reveal:Maze Assignment Full Reveal:Week 3Week 3

March 11March 11► Create a GUICreate a GUI► test mazestest mazes

minimum: report problemsminimum: report problems better: highlight offending part of maze, step better: highlight offending part of maze, step

through all problems detectedthrough all problems detected ideal: automatically repair problems when ideal: automatically repair problems when

possiblepossible

► edit mazes interactivelyedit mazes interactively► design mazes automaticallydesign mazes automatically