您如何在非平凡的应用程序中进行TDD? [英] How do you do TDD in a non-trivial application?

查看:96
本文介绍了您如何在非平凡的应用程序中进行TDD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了许多有关TDD的书籍和网站,它们都非常有意义,尤其是Kent Beck的书。但是,当我尝试自己进行TDD时,我发现自己盯着键盘想知道如何开始。您有使用的程序吗?您的思考过程是怎样的?您如何确定您的第一个测试?

I've read a number of books and websites on the subject of TDD, and they all make a lot of sense, especially Kent Beck's book. However, when I try to do TDD myself, i find myself staring at the keyboard wondering how to begin. Is there a process you use? What is your thought process? How do you identify your first tests?

关于该主题的大多数书籍都在描述TDD是什么方面做得很好,但是却没有如何练习 TDD在现实世界中的重要应用中。您如何进行TDD?

The majority of the books on the subject do a great job of describing what TDD is, but not how to practice TDD in real world non-trivial applications. How do you do TDD?

推荐答案

我曾经遇到过同样的问题。过去,我通常通过启动窗口设计器来为我要实现的第一个功能创建UI来开始大多数开发。由于UI是最难测试的方法之一,因此无法很好地转换为TDD。

I used to have the same problem. I used to start most development by starting a window-designer to create the UI for the first feature I wanted to implement. As the UI is one of the hardest things to test this way of working doesn't translate very well to TDD.

我发现Presenter First上的原子对象论文非常有帮助。我仍然首先设想要实现的用户操作(如果您有用例,这是一个很好的入门方式),然后使用MVP或MVC-ish模型,首先为第一个屏幕的演示者编写测试。通过模拟视图直到演示者可以正常工作,我可以用这种方式快速上手。 http://www.atomicobject.com/pages/Presenter+First 这里是更多信息

I found the atomic object papers on Presenter First very helpful. I still start by envisioning user actions that I want to implement (if you've got usecases that's a great way to start) and using a MVP or MVC-ish model I start with writing a test for the presenter of the first screen. By mocking up the view until the presenter works I can get started really fast this way. http://www.atomicobject.com/pages/Presenter+First here's more information on working this way.

如果您以未知或不熟悉的语言或框架启动项目,则可以先进行尖峰处理。我也经常为尖峰编写单元测试,但只是为了运行我所加的代码。进行尖峰处理可以为您提供一些有关如何启动实际项目的信息。开始真正的项目时,别忘了扔掉您的峰值

If you're starting a project in a language or framework that's unknown to you or has many unknown you can start out doing a spike first. I often write unit tests for my spikes too but only to run the code I'm spiking. Doing the spike can give you some input on how to start your real project. Don't forget to throw away your spike when you start on your real project

这篇关于您如何在非平凡的应用程序中进行TDD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆