我目前正在为 MutationTesting 编写一个框架。代码几乎是完整的,但有一点(花了半天时间)我无法弄清楚:
通过反射,我想执行“TestClass”类中的方法“TestMethod”。“TestClass”所在的项目引用了一个组件,我们称之为“Proband.dll”。
“TestMethod”在 Proband.dll 中创建某种类型的对象并在该对象上执行方法。
为了澄清一点:TestClass - 是一个包含单元测试的类。TestMethod - 是一个单一的单元测试。Proband.dll - 包含要测试的方法/类。
在执行 TestMethod 之前,我已经成功地对 Proband.dll 进行了反汇编、变异和重组。所以现在我有一个新的“Proband.dll”,它将由 TestClass 代替!
问题是 TestClass 已经在执行中。我在想是否可以创建一个 AppDomain 来加载新的 Proband.dll 并在新的 AppDomain 中执行 TestMethod。
我已经创建了这个 AppDomain 并成功地将新的 Proband.dll 加载到其中,但是,我不知道如何在这个新的 AppDomain 中执行 TestMethod。另外我不知道这是否会“替换”旧的 Proband.dll 用于测试方法。
这是我的测试类:
[TestClass()]
public class TestClass
{
[TestInitialize()]
public void MyTestInitialize()
{
// code to perform the mutation.
// From here, the "TestMethod" should be called with
// the new "Proband.dll".
}
[TestMethod()]
public void TestMethod()
{
// test code calling into Proband.dll
}
}
有谁知道如何实现这一目标?或者任何线索或关键字?
谢谢,克里斯蒂安