开发者

rails controller test: change the default tests or leave them untouched

开发者 https://www.devze.com 2023-02-15 16:11 出处:网络
After scaffoldinga new class, rails creates the correspondig tests for each controller method. What do you think, is best practice in a strikt TDD approach? Is it better, to leave these default tests

After scaffolding a new class, rails creates the correspondig tests for each controller method.

What do you think, is best practice in a strikt TDD approach? Is it better, to leave these default tests untouched and to create new tests for each new logic? (Even, if they overlap and verify almost the same things?) Or is it ok to extend these default tests with new assertions?

开发者_如何学运维

TIA, rufus!


Remove the default tests if they don't test stuff you need tested. If you leave them, you're padding your numbers, but the tests won't actually help you in the long run.


Just like with the scaffolding views and controller, you end up replacing most of the default code with your own, it's just a great place to get started.

In general, I would say remove them if you're not using them, or build on them if they can be extended to fit your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号