有沒有人有任何創建自定義測試類和使用接口的路徑?我有一個情況,我需要動態生成測試方法,這似乎是我需要的。我的目標是根據我測試的一些文件生成測試方法。使用IProvideDynamicTestMethods進行Silverlight 4單元測試
Jeff Wilcox在SL3中提到了這個新功能(http://www.jeff.wilcox.name/2008/09/rc0-new-test-features/,請參閱動態測試方法部分),但我找不到任何這方面的例子。
我不知道如何註冊我的自定義測試類(它繼承自ITestClass)。我看着SL4單元測試源代碼才能看到測試類是如何被發現,我發現在UnitTestFrameworkAssembly.cssource link
/// <summary>
/// Reflect and retrieve the test class metadata wrappers for
/// the test assembly.
/// </summary>
/// <returns>Returns a collection of test class metadata
/// interface objects.</returns>
public ICollection<ITestClass> GetTestClasses()
{
ICollection<Type> classes = ReflectionUtility.GetTypesWithAttribute(_assembly, ProviderAttributes.TestClass);
List<ITestClass> tests = new List<ITestClass>(classes.Count);
foreach (Type type in classes)
{
tests.Add(new TestClass(this, type));
}
return tests;
}
看起來它總是使用下面的內置識別TestClass。 我錯過了什麼嗎?我不知道如何讓測試框架使用我的自定義TestClass
任何指針讚賞。 謝謝