c# - Maintaining a singleton object in WatiN tests -


i have problem keeping object singleton in nunit tests.

this base class:

[testfixture] public class suitebase {     public mylib lib = null;      [testfixturesetup]     public void testfixturesetup()     {         lib = mylib.instance;     }      [testfixtureteardown]     public void testfixtureteardown()     {     } } 

and 1 of test suites.

[testfixture] public class suite1 : suitebase {     [test]     public void test1()     {         lib.foo();         //...     }      [test]     public void test2()     {         lib.bar();         //...     } } 

and mylib class defined following:

//singleton class public sealed class mylib {     public ie browser;     //other public fields...      public static mylib instance     {                 {             if (instance == null)             {                 instance = new myliblib();                  using (streamwriter sw = new streamwriter(@"c:\test.txt", true))                 {                     sw.writeline("creating object");                     sw.flush();                 }             }              return instance;         }     }      private static mylib instance;      private mylib()     {         browser = new ie();         //init rest of public fields     } } 

the problem singleton class object being created every test, run using:

int result = nunit.consolerunner.runner.main(new string[] {  "/run:" + myassembly.getname().name + testsuitename + "." + testcasename, myassembly.location,                              "/process:single",                             "/domain:single",                             "/nothread",                             "/timeout:" + testtimeout         }     ); 

any idea appreciated. thanks.

after changing "/domain:single" "/domain:none", creating single object now


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -