测试框架允许测试依赖于其他测试 [英] Test framework allowing tests to depend on other tests

查看:32
本文介绍了测试框架允许测试依赖于其他测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个测试框架允许将测试声明为依赖于其他测试.这意味着如果它们所依赖的测试未通过,则不应运行它们,或者不应突出显示它们的结果.

I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests. This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.

这种设置的目的是在存在许多测试失败的情况下更容易确定根本原因.

The point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.

作为奖励,如果有某种方法可以使用通过一个测试创建的对象作为其他测试的夹具,那就太好了.

As a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.

此功能集是否由任何 Python 测试框架提供?或者,这种方法是否与单元测试的基本理念背道而驰?

Is this feature set provided by any of the Python testing frameworks? Or would such an approach be antithetical to unit testing's underlying philosophy?

推荐答案

或者这样的方法是与单元测试相反基本哲学?

Or would such an approach be antithetical to unit testing's underlying philosophy?

是的...如果是单元测试,它应该能够自行运行.任何时候我发现有人想要创建对测试的依赖都是因为代码的结构很差.我并不是说这是你的例子,但它通常可能是代码异味的迹象.

Yep...if it is a unit test, it should be able to run on its own. Anytime I have found someone wanting to create dependencies on tests was due to the code being structured in a poor manner. I am not saying this is the instance in your case but it can often be a sign of code smell.

这篇关于测试框架允许测试依赖于其他测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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