I am trying to make some Junit tests for a tic tac toe board. I know how to test one function at a time, but my problem is that in order to check some function, previous functions must be called.
For example, in order to check a winner, you have to call the function "PlaceMarker" function multiple times. The specific one I'm on is checking to make sure the bool function "CheckSpace" returns false when there is already a marker in the spot its checking. I currently have
public class TestGame {
private GameBoard board;
@Before
public void setUp() {board = new GameBoard();}
@After
public void tearDown() {board = null;}
@Test
public void testRewritingOverSpace() {
assertEquals("Placing (1, 1), then checking space (1, 1)", false,
board.placeMarker(new BoardPosition(1, 1, 'X')),
board.checkSpace(new BoardPosition(1, 1, 'O'));
This is giving me a error. So in short, how do you make a JUnit test case in whcih you have to call multiple functions.
Aucun commentaire:
Enregistrer un commentaire