Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何检查哪个测试脚本是/将是最后执行的?(使用C#和NUnit)_C#_Selenium Webdriver_Nunit - Fatal编程技术网

如何检查哪个测试脚本是/将是最后执行的?(使用C#和NUnit)

如何检查哪个测试脚本是/将是最后执行的?(使用C#和NUnit),c#,selenium-webdriver,nunit,C#,Selenium Webdriver,Nunit,在自动化测试解决方案(C#和Nunit)中,我想获取最后执行的测试脚本的名称。作为对您问题的直接回答。。。这不是很容易,但有可能 您可以创建引用静态变量的[onetimeeardown]和[TearDown]方法。比如说 private static string _lastTestRun; [OneTimeTearDown] public void RecordLastTestCase() { // Do what you like with _lastTestRun } [Tea

在自动化测试解决方案(C#和Nunit)中,我想获取最后执行的测试脚本的名称。

作为对您问题的直接回答。。。这不是很容易,但有可能

您可以创建引用静态变量的
[onetimeeardown]
[TearDown]
方法。比如说

private static string _lastTestRun;

[OneTimeTearDown]
public void RecordLastTestCase()
{
    // Do what you like with _lastTestRun
}

[TearDown]
public void My TearDown()
{
    _lastTestRun = TestContext.CurrentContext.Test.Name;
}

你还没有说你想用这些信息完成什么。根据具体情况,可能会有更简单的方法。

由于“测试脚本”不是NUnit中使用的术语,不同的人使用它的方式不同,请定义它的含义,以便我们给出答案。例如,您正在谈论一个测试用例吗?固定装置?等等@Charlie-我说的测试脚本是指一个测试用例。