March 2018
Intermediate to advanced
324 pages
8h 30m
English
We'll create a TicTacToeInteg class inside the com.packtpublishing.tddjava.ch03tictactoe package in the src/test/java directory. Since we know that Jongo throws an exception if it cannot connect to the database, a test class can be as simple as the following:
import org.junit.Test;
import java.net.UnknownHostException;
import static org.junit.Assert.*;
public class TicTacToeInteg {
@Test
public void givenMongoDbIsRunningWhenPlayThenNoException() throws UnknownHostException {
TicTacToe ticTacToe = new TicTacToe();
assertEquals(TicTacToe.NO_WINNER, ticTacToe.play(1, 1));
}
}
The invocation of assertEquals is just as a precaution. The real objective of this test is to make sure that no Exception is thrown. Since we did not ...
Read now
Unlock full access