unit testing level game. create pieces array call move or interact use getters or return type to...

7
Unit Testing LEVEL GAME

Upload: pierce-sparks

Post on 05-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

Unit TestingLEVEL GAME

Page 2: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

Create pieces arrayCall move or interactUse getters or return type to verify correct behavior

Test ends (don’t go <0 or >GameEngine.BOARD_SIZE-1)

If interact with adjoining piece, put that piece & yours on board

If interact within range, be sure to test locations within range PLUS one beyond

TEST INDIVIDUAL PIECES

Page 3: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

Can’t test random behavior deterministicallyNeed to run method multiple times

Do all possible results actually occur? Do the possible results account for ALL results? (i.e., no

invalid moves)What if LOTS of valid results? (e.g., any location)

Test ends Identify “categories” of possibilities

If limited number of possibilities, test each one E.g., move one to right or left

TEST RANDOM MOVEMENT

Page 4: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

What if the player is within “range” of more than one piece?

We’re not testing this, but the approach would be: Create a GameEngine Create a pieces array Add a setter to GameEngine for the pieces array Call interaction

TEST INTERACTION

Page 5: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

BLACK BOX VS WHITE BOX

Criteria Black Box Testing White Box Testing

Definition

Black Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is NOT known to the tester

White Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is known to the tester.

Levels Applicable To

Mainly applicable to higher levels of testing:Acceptance TestingSystem Testing

Mainly applicable to lower levels of testing:Unit TestingIntegration Testing

Responsibility Generally, independent Software Testers

Generally, Software Developers

Programming Knowledge Not Required Required

Implementation Knowledge Not Required Required

Basis for Test Cases Requirement Specifications Detail Design

From: http://softwaretestingfundamentals.com/differences-between-black-box-testing-and-white-box-testing/

Page 6: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

Analyze control flow graphFind linearly independent paths of executionGuarantees complete branch coverageDoes not cover all possible paths

http://www.tutorialspoint.com/software_testing_dict ionary/basis_path_testing.htm

http://users.csc.calpoly.edu/~jdalbey/206/Lectures/basispathEg.html

BASIS PATH TESTING (WHITE BOX)

Page 7: Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)

Method to test all the possible discrete combinations of the parameters involved.

http://www.tutorialspoint.com/software_testing_dict ionary/al l_pairs_testing.htm

ALL PAIRS TESTING