我想從開始運行測試n次,即退出驅動程序並再次運行設置。但重試屬性不會退出驅動程序,它只是再次運行測試用例。Nunit 3次重試n次
[TestFixture(typeof(ChromeDriver))]
public class TestWithMultipleBrowsers<TWebDriver> where TWebDriver : IWebDriver, new()
{
#region Setup
private IWebDriver driver;
[TestFixtureSetUp]
public void CreateDriver()
{
if (typeof(TWebDriver).Name == "ChromeDriver")
{
driver = new ChromeDriver(@"C:\ChromeDriver");
}
else
{
driver = new TWebDriver();
}
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
if (driver != null) driver.Quit();
}
[Test,Retry(2)]
[TestCase("jobsearch")]
[TestCase("employer")]
public void GoogleTest(string search)
{
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys(search + Keys.Enter);
Thread.Sleep(1000);
Assert.AreEqual(search + " - Google Search", driver.Title);
}
#endregion
}
從命令行運行測試是一個選項嗎? – dotctor