找不到Assert.Fail和Assert.Pass或等效项 [英] Cannot find Assert.Fail and Assert.Pass or equivalent
问题描述
我以前在NUnit中使用它们,它们确实很有用.你知道怎么做那样的事吗?
I used to use these in NUnit and they are really useful. Any idea how to do something like that?
编辑,代码示例:
bool condition = false;//would be nice not to have this
observable.Subscribe(_ =>
{
if (real test)
condition= true;//Assert.Pass()
});
StartObservable();
Assert.True(condition);//Assert.Fail()
推荐答案
文档包括比较表包括以下内容:
The documentation includes a comparison chart including this:
失败
-xUnit.net替代:Assert.True(false,"message")
Fail
- xUnit.net alternative:Assert.True(false, "message")
(它没有显示 Assert.Pass
,而且我自己从未使用过,但是我怀疑替代方法只是从测试中返回.当然,如果您想将其放入嵌套方法调用中.我的怀疑是,它在NUnit中使用不多,因此在比较表中不存在.)
(It doesn't show Assert.Pass
, and I've never used that myself, but I suspect the alternative is just to return from the test. Of course that doesn't help if you want to throw it in a nested method call. My suspicion is that it's not very frequently used in NUnit, hence its absence in the comparison chart.)
这篇关于找不到Assert.Fail和Assert.Pass或等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!