puppeteer-sharp
puppeteer-sharp copied to clipboard
Align per-test and per-class disposal
In NUnit the constructor and Dispose(Async) methods are run once per class, whereas methods marked with [SetUp] or [TearDown] are run once per test.
In PuppeteerBrowserBaseTest we hence:
- Before each test: construct a new
Browser - After each test: close
Browser - At the last test: dispose the last created
Browser
Unless I'm missing something, each Browser instance should be handled equally.
b957d9ba2b38d366963cc482ed3caf504248ed54 introduced this asymmetry but I don't understand why.
If we want to keep this asymmetry, let's at least add a comment why we close all browser, but only dispose the last one.
@jnyrup ideally, I would love to keep one browser per LaunchOption! I think that's how it worked back in the XUnit. days.
If we get to do that, it would be awesome. If not. I would like to keep one browser per class rather than per test.
Only opening a browser per unique LaunchOptions would get us from +900 browsers and down to ~10.
And if we still open a Browser per class, we should still get us down to ~175.
This was more complicated than I expected as NUnit3 doesn't call IAsyncDisposable, but NUnit4 does.
I'll be happy to upgrade the project to NUnit4 (I just tried it out, and it looks quite nice), but I'm away from my computer the next two weeks.
@jnyrup Let's go for NUnit4 when you can :)
I won't get around looking at this any time soon. (It also seems to me that the tests have been more stable the past months)
Thank you, @jnyrup. I tried to make it work. But tests weren't happy about it