“Hello World” - The TDD way?

前端 未结 10 873
感动是毒
感动是毒 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:38

    Presenter-View? (model doesn't seem strictly necessary)

    View would be a class that passes the output to the console (simple single-line methods)

    Presenter is the interface that calls view.ShowText("Hello World"), you can test this by providing a stub view.

    For productivity though, I'd just write the damn program :)

    A single test should suffice (in pseudocode):

    IView view = Stub();
    Expect( view.ShowText("Hello World") );
    
    Presenter p = new Presenter( view );
    p.Show();
    
    Assert.IsTrue( view.MethodsCalled );
    

提交回复
热议问题