Setup and Teardown attribute methods not getting invoked using Nunit-3.11 and Visual Studio - 2017
using GV5Base;
namespace DBPAutomation.Test
{
[TestClass]
public class Training
{
public IWebDriver driver;
// initializing the driver and open the browser
[SetUp]
public void BrowserInitialize()
{
Base bs = new Base();
bs.SetBrowser("Chrome");
driver = bs.driver;
}
}
}
namespace Base
{
[TestClass]
class Base
{
public IWebDriver driver;
public string TestUrl = "http://google.com";
public void SetBrowser(string browser)
{
if(browser == "Chrome")
{
this.driver = new ChromeDriver();
driver.Navigate().GoToUrl(TestUrl);
}
else if(browser == "IE")
{
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl(TestUrl);
}
}
On execution getting System.NullReferenceException: Object reference not set to an instance of an object.
Because Setup method is not getting invoked
Also tried with OneTimeSetup and OneTimeTeardown even these options not working