I have this first integration test for a tic tac toe game:
[TestClass]
public class FirstIntegrationTest
{
[TestMethod, TestCategory("Integration Tests")]
public void Standard_TicTacToe_Game_PlayerO_Wins()
{
IPlayer playerO = new Player();
IPlayer playerX = new Player();
Game game = new Game(playerO, playerX);
game.Start();
playerO.Play(new Point(0, 0));
playerX.Play(new Point(2, 2));
playerO.Play(new Point(1, 0));
playerX.Play(new Point(1, 2));
playerO.Play(new Point(2, 0));
Assert.IsTrue(game.IsOver);
Assert.IsTrue(playerO.HasWon);
Assert.IsFalse(playerX.HasWon);
}
}
Later I will add at least another one that takes care of showing up on to the User the board of the game. For the current one, I am only interested in what is shown above.
When doing integration tests (and this is an integration test, I suppose?) what kind of Unit-Tests should I do? Should I just make the minimum just to make the Integration Test pass? If that is so, I’d only need to make the Game class set its first IPlayer HasWon to true and the second one to false. What would be the point of Unit-Testing at all if I’m driving my design by the integration tests?
I have the idea that generally you don’t have a lot of integration tests. So, should I be driving my design by Integration-Tests or by Unit-Tests?
algorithms are always the hardest to test, because to be truly sure it works, you have to test every possible combination of everything. Realistically, its up to you to decide where to draw the line.
What you have here is a high level acceptance test.
possible unit tests are: