我有两个[TestMethods]。 MethodA的结果需要是MethodB的输入。问题是,当新的测试方法启动时,所有的值和变量都会被重置。VS 2010:将TestMethod的结果传递给另一个Testmethod
有人已经问过exact same question,但还没有真正的解决方案。
我要的是下面的工作:
Guid CustomerID;
[TestMethod]
public void CreateCustomer()
{
// Create a new customer and store the customer id
CustomerID = CreateNewCustomer();
Assert.IsNotNull(...);
}
[TestMethod]
public void DeleteCustomer()
{
// Delete the customer created before
var ok = DeleteCustomer(CustomerID);
Assert.IsNotNull(...);
}
我明白,这不是测试“官方”的方式,但我确实需要为这种情况的实际解决方案 - 所以我希望某种解决方法。
任何想法?
嗨,山姆,谢谢你的帮助。 – Ingmar 2011-03-15 12:30:26
Sh ...命中意外返回;-)好吧,这个想法是在测试运行中创建一个新客户,然后再次在完全相同的测试运行中删除同一个客户。所以,最后,如果一切都完成了,那么在每次测试之后数据库都会再次变空。 – Ingmar 2011-03-15 12:34:53
@Ingmar,看看我的编辑,你需要确保如果一切都没有解决,数据库被重置为可行状态,以便其他测试不受影响。这可以在TestFixtureSetup中或拆卸下来。我将编辑以包含此信息 – 2011-03-15 12:36:21