c# - xUnit and Watin cleanup -



c# - xUnit and Watin cleanup -

i have test cases using xunit , watin. create facts in class share same instance of ie, had created singleton class first test launch new ie instance, , next tests utilize same instance.

after facts finish, ie instance still running. wonder how close ie after tests in class finish.

for purpose class tests need implement iuserfixture interface. i'll provide illustration solves needs , demonstrates xunit life-cycle model:

public class mytestclass : iusefixture<watinfixture>, idisposable { private watinfixture _data; public void setfixture(watinfixture data) { _data = data; console.writeline("setting info test"); } public mytestclass() { console.writeline("in constructor of mytestclass"); } [fact] public void fact1() { console.writeline("in fact1. ie '{0}'", _data.referencetoie); // utilize _data.referencetoie here } [fact] public void fact2() { console.writeline("in fact2. ie '{0}'", _data.referencetoie); // utilize _data.referencetoie here } public void dispose() { console.writeline("in dispose of mytestclass"); } } public class watinfixture : idisposable { public string referencetoie = null; public watinfixture() { // start ie here console.writeline("starting ie ..."); referencetoie = "if see string - browser reference not empty."; } public void dispose() { // close ie here console.writeline("closing ie ..."); referencetoie = null; } }

output:

starting ie ... in constructor of mytestclass setting info test in fact1. ie 'if see string - browser reference not empty.' in dispose of mytestclass in constructor of mytestclass setting info test in fact2. ie 'if see string - browser reference not empty.' in dispose of mytestclass closing ie ...

c# watin xunit resource-cleanup

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -