我正在尝试编写一个pex测试,我注意到它总是提供一个假的值作为我想要的参数之一。
[PexMethod]
public void TestCtor(bool value)
{
ArbitraryType myType = new ArbitraryType(value);
}我想测试一个场景,让pex进行探索,确保value是真的。我做了另一个测试,看起来像这样:
[PexMethod]
public void TestCtor(bool value)
{
Contract.Requires(value == true);
ArbitraryType myType = new ArbitraryType(value);
}问题是,为什么Pex不能满足代码约定?
发布于 2011-07-29 10:56:00
我不确定Pex将在测试方法中对合同做什么,但我认为这不是一件好事:)
如果您想让Pex这样做,正确的做法是使用PexAssume.IsTrue(value)。
https://stackoverflow.com/questions/6862999
复制相似问题