2

I have several files that will require access to an object, which I want initialized only once. I considered making a static variable, but I'd rather stay away from that. Here's my question along with code:

[SetUpFixture] public class TestSetup { public IWebDriver driver; [SetUp] public void SetUp() { driver = new ChromeDriver(); } [TearDown] public void TearDown() { driver.Dispose(); } } 

Do my tests within the namespace of this SetUpFixture have access to driver?

EDIT: Looks like an approach to this is answered here. I'm still open to other options than what Jon pointed out.

2
  • 1
    You could have a static class that creates the driver object or make a driver factory class that is not static but creates instances of the driver. Commented May 4, 2015 at 22:35
  • 1
    stackoverflow.com/questions/29079070/… Commented May 4, 2015 at 22:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.