你有任何測試的實踐經驗嗎?

才智咖 人氣:3.11W

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.
參考翻譯

測試你想做的一切

在你的測試用例的測試方法比你更多的類測試

試驗應儘可能細

測試應該是獨立的

不宜長時間跑(幾秒鐘)

易於理解和閱讀

使他們安全

開發商必須知道,他們沒有破壞性

所有開發人員必須瞭解他們

每一個觸控程式碼的'人都必須執行測試。

確定您的程式碼的多少是由測試覆蓋的

如果開發人員更改功能,則可能需要更新測試

警告:您已經更改了介面。你打破別人了嗎?

甚至更好,所有測試通過,新的測試,增加了新的程式碼

所有的測試都通過所有的時間

不要讓哪怕是一次“失敗”

追蹤並修復損壞的測試

自動化測試

如所有的測試程式碼提示修改得到的失敗每日自動執行電子郵件。

執行測試程式碼簽入

部署前執行測試

有一個合理的生產環境在開發區複製。