我正在尝试对我的 ASP.NET 应用程序进行一些自动化 Web 测试。我希望使用 Xunit.net 扩展中的 AutoRollback 属性来撤消测试期间所做的任何数据库更改。AutoRollback 使用 TransactionScope 在测试之前启动事务并在之后回滚。
当我尝试在事务期间访问我的 Web 应用程序时,它总是超时。看起来这应该可行,有什么想法吗?这是我的测试:
[Fact]
[AutoRollback]
public void Entity_should_be_in_list()
{
Entity e = new Entity
{
Name = "Test",
};
dataContext.Entities.InsertOnSubmit(e);
dataContext.SubmitChanges();
selenium.Open("http://localhost/MyApp");
Assert.True(selenium.IsTextPresent("Test"));
}