Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDD #15

Open
vonzhou opened this issue Dec 14, 2019 · 0 comments
Open

TDD #15

vonzhou opened this issue Dec 14, 2019 · 0 comments

Comments

@vonzhou
Copy link
Owner

vonzhou commented Dec 14, 2019

谈谈对TDD的感受。

维基百科定义:

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved so that the tests pass. This is opposed to software development that allows software to be added that is not proven to meet requirements.

TDD由kent beck于2003年提出,kent出了好几本好书。

工作好几年了,从最开始的不写测试用例,到后来的推荐写用例,再到现在的强制用例覆盖,自己对测试用例的认知也在慢慢改变。

之前的做法是先实现功能,然后本地或者部署到dev环境,用postman接口测试,有问题修改后再部署,如此往复,有一种很混沌的感觉,而且每次部署都比较慢。

TDD可以让自己更有信心, 测试用例能通过,基本逻辑就不会有大的问题,而且各种边界情况都可以覆盖到,代码修改或重构后,如果有测试用例就会实现小步快跑。

现在的做法是从入口处,先把核心的接口定下来,然后写测试用例,外部系统交互采用Mock的方式,然后填充接口的实现直到测试用例通过。为了解决本地测试用例连接dev数据慢的问题,可以集成测试环境使用内存数据库,在支持依赖注入的框架下很容易。

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant