什么是“坏"?单元测试中的属性? [英] What are "bad" attributes in unit tests?

查看:24
本文介绍了什么是“坏"?单元测试中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚阅读了问题,其中回答了单元测试的理想特性,但是应该避免什么?是什么让单元测试变得糟糕"?

I just read question that answered what were desirable features of unit tests, but what should be avoided? What makes a unit test "bad"?

你见过的最糟糕的单元测试是什么?(例如.我记得一位开发人员告诉我,他曾经发现一个测试套件有很多方法,但完全没有任何断言).

What are the worst unit tests you've seen? (For example. I remember a developer telling me he once found a test suite with plenty of methods but completely devoid of any asserts).

我对单元测试中更微妙和更具体的问题特别感兴趣,例如假设您有一个运行速度快、覆盖率高的测试套件,它还有什么问题?

I'm particularly interested in slightly more subtle and specific problems with unit tests e.g. suppose you have a test-suite that runs quickly with good coverage, what problems could it still have?

推荐答案

  • 使用外部依赖项(数据库、文件、服务器、时间...)进行测试

    • Tests with external dependencies (DB, file, server, time...)

      相互依赖的测试

      验证实现而非行为的测试

      Tests that verify the implementation rather than the behavior

      太慢以至于没人执行的测试

      Tests that are so slow that no one execute them

      测试太多东西

      还有 TDD 反模式.

      这篇关于什么是“坏"?单元测试中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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