当我创建PUT时,“Run Pex”将使用这一方法,并为之进行自动生成测试。
只要对这种方法的号召直接在中央直辖区内进行,这只能奏效。
样本:
The PUT is used by “Run Pex”:
[PexGenericArguments(typeof(string))]
[PexGenericArguments(typeof(int))]
[PexGenericArguments(typeof(object))]
[PexMethod]
public string Convert01_ConverterForTypeNotRegistered<T>(
[PexAssumeUnderTest] ToStringConverter target, T objectToConvert)
{
var result = "";
result = target.Convert(objectToConvert);
return result;
}
The PUT is not used by “Run Pex”:
[PexGenericArguments(typeof(string))]
[PexGenericArguments(typeof(int))]
[PexGenericArguments(typeof(object))]
[PexMethod]
public string Convert01_ConverterForTypeNotRegistered_ThrowsInvalidOperationException<T>(
[PexAssumeUnderTest] ToStringConverter target, T objectToConvert)
{
var result = "";
PexAssert.Throws<InvalidOperationException>(() => target.Convert(objectToConvert));
return result;
}
我想表明,要求采用这种方法总是放弃这一例外,而不考虑参数。
如何做到这一点?
我已经询问,一周前,在
这个问题可如下文所示:
<class-name>Test.cs
and <class-name>Test.<MethodName>.g.cs
. In the first file, there is the PUT, in the second files are the specific test methods, one for each parameter Pex chooses. The second file is automatically recreated every time you run pex for a method that has a PUT in the first file.