“Hello World” - The TDD way?

前端 未结 10 981
感动是毒
感动是毒 2021-01-31 21:10

Well I have been thinking about this for a while, ever since I was introduced to TDD. Which would be the best way to build a \"Hello World\" application ? which would print \"H

10条回答
  •  我在风中等你
    2021-01-31 21:43

    I agree with David Berger; separate off the interface, and test the model. It seems like the "model" in this case is a simple class that returns "Hello, world!". The test would look like this (in Java):

      Greeter greeter = new Greeter();
      assertEquals("Hello World!", greeter.greet());
    

    I've created a write up of solving Hello World TDD style at http://ziroby.wordpress.com/2010/04/18/tdd_hello_world/ .

提交回复
热议问题