测试取决于NUnit的常用功能

测试取决于NUnit的常用功能

本文介绍了测试取决于NUnit的常用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一些初始化代码可以使用我的API.初始化可能会失败,我想在NUnit测试中对其进行测试.

I have some initialization code to use my API. The initialization may fail and I´d like to test it in an NUnit test.

初始化之后,可以使用API​​.我也在测试API,但是我所有的测试方法都将使用相同,通用的初始化代码.

After the initialization the API may be used. I´m testing the API too, but all my test methods will use the same, common, initialization code.

如果发生这种情况,我理想的情况是:

What I would ideally like is if this behavior:

  1. 正在运行初始化测试.
  2. 如果[1]成功,则将运行其他测试.

在所有情况下,[1]都会失败,其他所有测试也会失败.但是有价值的信息是[1]失败了.那是我最有可能找到问题的地方.如果其他测试可以标有?,那将是很好的.或类似的东西,表明它们没有作为他们所依赖的功能执行而未通过测试.

In all cases where [1] will fail, so will all other tests. But the valuable information is that [1] fails. That's where I most likely will find the problem. It would be nice if the other tests could be marked with ? or something, indicating that they did not execute as functionality they depend on didn't pass the tests.

我知道测试不应该很脆弱.但是我无法回避这样的事实,即初始化代码对于正确执行其他功能是必需的.

I know that tests should not be brittle. But I can't get around the fact that the initialization code is necessary for correct execution of other functionality.

这是一个更普遍的问题,其中某些功能取决于其他功能.如果其他功能"太过普遍而无法通过依赖于它的所有测试来提供任何实际价值的地方.最好单独测试其他功能".

This is a more general problem where some functionality depends on other functionality. Where the "other functionality" is far too commonly used to provide any real value by failing all tests depending on it. It would be better if the "other functionality" would be tested separately.

推荐答案

我一直在与NUnit开发人员联系.如果不编写一个非常复杂的插件,目前是不可能的.该功能将在3.x代码库的某个地方出现,但不会在2.5中出现.我会考虑编写它,但暂时不做.

I've been in contact with the NUnit developers. It's not possible at the moment without writing a pretty complex plugin. The feature will turn up somewhere in the 3.x code base but will not appear in 2.5. I will consider writing it, but not for the time being.

这篇关于测试取决于NUnit的常用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:52