- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试重新组织我们拥有的一些集成测试,以便它们使用一个公共(public)类来创建数据库和数据库中所需的数据,以使用 [SetUpFixture] NUnit 属性在同一程序集中的其他类中进行测试。
我有:
namespace Tests;
public class TestBaseClass : SolutionBaseClass
{
public void Setup()
{
base.CreateDatabase();
base.CreateData();
}
public void Teardown()
{
base.DestroyDatabase();
}
}
[SetUpFixture]
public class Setup : TestBaseClass
{
[SetUp]
public void Setup()
{
base.Setup();
}
[TearDown]
public void Teardown()
{
base.Teardown();
}
}
然后是单独的测试夹具类:
namespace Tests.Services;
[TestFixture]
public class LibraryTest : TestBaseClass
{
[TestFixtureSetUp]
public void SetupTests()
{
// I know am calling the same Setup twice once from SetUpFixture and TestFixture,
// I have handled it so that only one Database/Data gets set up once (for safety mostly!)
base.SetUp();
// Other class initialisations.
}
}
任何想法我做错了什么,我认为这是使用的继承模型的问题,因为你可以看出我是从别人那里继承的!!
谢谢。
最佳答案
在 NUnit 3 中,应该在 [SetUpFixture] 类的静态方法上使用 OneTimeSetUpAttribute 和 OneTimeTearDownAttribute。来源:http://bartwullems.blogspot.nl/2015/12/upgrading-to-nunit-30-onetimesetup.html
在 NUnit 2.0 中
[SetUpFixture]
class TestHost
{
[SetUp]
public static void AssemblyInitalize()
{
//Global initialization logic here
}
}
在 NUnit 3.0 中
[SetUpFixture]
class TestHost
{
[OneTimeSetUp]
public static void AssemblyInitalize()
{
//Global initialization logic here
}
}
关于c# - NUnit - 失败,SetUpFixture 上不允许使用 TestFixtureSetUp 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25401747/
我们使用 TeamCity 作为 CI 服务器,我刚刚开始在测试失败窗口中看到“TestFixtureSetUp Failed”。 知道如何调试这个问题吗?测试在我的工作站上运行良好(VS2008 中
我在 Visual Studio 2010 中使用 NUnit 2.6 和 Visual NUnit 进行了基本测试设置。我的问题是,当我运行所有测试时,似乎 FixtureSetup 方法(具有 T
NUnit 文档没有告诉我何时使用带有 TestFixtureSetup 的方法以及何时在构造函数中进行设置。 public class MyTest { private MyClass my
在我的测试中,下一个流程发生了: 我在所有测试运行之前执行一些操作(例如购买产品) 然后在每个测试中我检查一个断言 我使用 NUnit 框架来运行测试,所以我使用 [TestFixtureSetUp]
我目前正在 NUnit 中编写一些集成测试,这些测试需要在 [TestFixtureSetUp] 方法内部完成一些设置。如果在设置过程中出现问题(例如无法连接到服务器),使方法失败并将其传达给 NUn
我在一个 TestFixture 中有多个 TestCase。我还有一个 TestFixtureSetup 方法 (Setup()) 和 TestFixtureTearDown 方法 (TearDow
在 NUnit 中,我们使用 TestFixtureSetUp MSTest 中的等效测试是什么? 谢谢 最佳答案 在这里你可以找到很好的表格,它并排显示 NUnit 和 MSTest 属性: htt
xUnit 相当于 NUnit 的 [TestFixtureSetUp] ? 我们探索发现IUseFixture相当于[TestFixtureSetUp] ,但它没有按预期工作。 正如我们所探索的(在
我正在尝试重新组织我们拥有的一些集成测试,以便它们使用一个公共(public)类来创建数据库和数据库中所需的数据,以使用 [SetUpFixture] NUnit 属性在同一程序集中的其他类中进行测试
我必须在 setup 上创建数据库事件并进入 teardown事件,当我没有使用时,流程正在工作 TestCaseSource .但是现在我必须使用TestCaseSource那么NUnit的执行顺序
我正在为我的测试项目使用 MBUnit,并且有一个设置例程必须在多个不同的测试装置正常运行之前运行。 目前,在每个 TestFixture 中,我在执行此操作的例程上都有 [TestFixtureSe
我正在尝试使用 CssSelector 在我的网页上定位一个元素。我正在使用 Firefox 驱动程序。 这是我使用定位器的方式(我检查过 Selenium IDE 能够用它定位我的元素 [Finds
我是一名优秀的程序员,十分优秀!