Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First TDD test with no assert/expected exception. Is it worth it?

Let's say I'm starting to do a game with TDD. Is this a good first test?

[TestMethod]
public void Can_Start_And_End_Game()
{
    Tetris tetris = new Tetris();
    tetris.Start();
    tetris.End();
}

It basically forces me to define 3 things: the Tetris class and its Start() and End() methods, but besides that it's pretty useless. It might have its interest immediately as with them I can define that class and those methods, but later it probably won't serve any kind of purpose. Its only purpose would maybe show that it must be possible to start a game and end it without getting an exception in the middle.

What are your thoughts on that?

like image 709
devoured elysium Avatar asked Jul 31 '10 22:07

devoured elysium


1 Answers

It basically forces me to define 3 things: the Tetris class and its Start() and End() methods,

True.

but besides that it's pretty useless.

False.

later it probably won't serve any kind of purpose

False, also.

Its ... purpose [is to] show that it must be possible to start a game and end it without getting an exception in the middle

And that's HUGE. Epic. Monumental.

Indeed, that test will fail so often that you'll grow to hate it. Every unhandled, uncaught exception from all kinds of random places in your program will fail this test. You'll build careful logging and debugging because of this test.

This test is EPIC.

like image 177
S.Lott Avatar answered Oct 08 '22 19:10

S.Lott