相关疑难解决方法(0)

如何实现XUnit描述性断言消息?

上下文

在XUnit github中我发现了这个:添加Assert.Equal(预期,实际,消息)重载#350 (所以开发人员要求不存在的重载请参见下文)

引用答案:

我们相信自我记录的代码; 包括你的断言.

(所以XUnit团队拒绝它)

好,我知道了.我也相信自我记录代码.我还是找不到这个用例:

样品

// Arrange
// Create some external soap service client and its wrapper classes

// Act
// client.SomeMethod();

// Assert
// Sorry, soap service's interface, behaviour and design is *given*
// So I have to check if there is no Error, and 
// conveniently if there is, then I would like to see it in the assertion message

Assert.Equal(0, client.ErrorMessage.Length); // Means no error

// I would like to have …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing xunit assertions xunit2

26
推荐指数
4
解决办法
1万
查看次数

标签 统计

assertions ×1

c# ×1

unit-testing ×1

xunit ×1

xunit2 ×1