你有任何测试的实践经验吗?

文学乐 人气:3.04W

Test everything that you want to work

你有任何测试的实践经验吗?

More test methods in your TestCase than in the class you are testing

Tests should be as fine grained as possible

Tests should be independent

Should not take long to run (a few seconds)

Easy to understand and read

Make them safe

Developers must know they are not destructive

All developers must know about them

Everyone who touches the code must run the tests.

Determines how much of your code is covered by tests

If developer changes functionality, they may need to update test

Warning: you’ve changed the interface. Did you break someone else?

Even better, all tests pass AND new tests were added for new code

All tests pass all the time

Don’t allow even one test the “always fails”

Track down and fix the broken test immediately

Automate running of tests

Ex. All tests on tip revision of code get run automatically once per day with failures emailed.

Run tests on code check-in

Run tests before deployment

Have a reasonable copy of your production environment in a dev area.
参考翻译

测试你想做的一切

在你的测试用例的测试方法比你更多的类测试

试验应尽可能细

测试应该是独立的

不宜长时间跑(几秒钟)

易于理解和阅读

使他们安全

开发商必须知道,他们没有破坏性

所有开发人员必须了解他们

每一个触摸代码的'人都必须运行测试。

确定您的代码的多少是由测试覆盖的

如果开发人员更改功能,则可能需要更新测试

警告:您已经更改了接口。你打破别人了吗?

甚至更好,所有测试通过,新的测试,增加了新的代码

所有的测试都通过所有的时间

不要让哪怕是一次“失败”

追踪并修复损坏的测试

自动化测试

如所有的测试代码提示修改得到的失败每日自动运行电子邮件。

运行测试代码签入

部署前运行测试

有一个合理的生产环境在开发区复制。