OneTimeSetUp 和 OneTimeTearDownStopped 工作
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
class Class1
{
[SetUp]
public void setup()
{
Console.WriteLine("setup method");
}
[TearDown]
public void teardown()
{
Console.WriteLine("teardown");
}
[OneTimeSetUp]
public void onetimesetup()
{
Console.WriteLine("onetimesetup method");
}
[OneTimeTearDown]
public void onetimeteardown()
{
Console.WriteLine("onetimeteardown method");
}
[Test]
public void testCase()
{
Console.WriteLine("Testcase method 2");
}
}
}
我之前安装了Resharper,现在我已经完成了resharper。 我已从 C:\Users kris\AppData\Local\Microsoft\VisualStudio 删除 resharper .0_d20cab45\扩展 而且我现在更多地将它放在控制面板中。
但我仍然有这个问题。我之前有一个项目运行良好。这是我从 nuget 包下载的包。 更准确地说,请找到我正在尝试完成的项目
TestFixture 没有任何问题(例如,这里有一个类似的问题),所以肯定是测试运行方式有问题,所以让我为您提供另一种运行测试的方法......
希望这有帮助。
在我的例子中,包含 [OneTimeSetUp] 的文件应该位于测试项目文件夹的根目录中。