当我在拆解中使用Assert.Pass()时,它会将测试用例标记为失败?我正在使用LatestNunit版本

时间:2016-06-06 09:55:16

标签: nunit assertions

当我在拆解中使用Assert.Pass()时,它会将测试用例标记为失败?我正在使用LatestNunit版本

在升级nUnit之前它工作正常!

1 个答案:

答案 0 :(得分:0)

TearDown显然不支持ResultStateExceptions - 请参阅源代码中的此注释。

    /// <summary>
    /// RecordTearDownException appends the message and stacktrace
    /// from an exception arising during teardown of the test
    /// to any previously recorded information, so that any
    /// earlier failure information is not lost. Note that
    /// calling Assert.Ignore, Assert.Inconclusive, etc. during
    /// teardown is treated as an error. If the current result
    /// represents a suite, it may show a teardown error even
    /// though all contained tests passed.
    /// </summary>

https://github.com/nunit/nunit/blob/ca8dc9fefa33be11f85cc1c8d2cf14e0fef51117/src/NUnitFramework/framework/Internal/Results/TestResult.cs#L508

这似乎是明智的 - 我不确定你想要强迫你的失败测试显示为传递的情况是什么?如果你有一个真正的用例,我建议发布一个Github问题来讨论它作为一个功能,但它听起来不是理想的方法。