3 ms·
I was recently involved in my first "integration testing" project involving Selenium, Winium, and ssh (doing cross-platform testing of an installer). One of th
by gregmac 7y ago
I was recently involved in my first "integration testing" project involving Selenium, Winium, and ssh (doing cross-platform testing of an installer).
One of the things that really struck me as I was reading through examples and such was how common it seems to be to have test code like "Click x; Wait 5 seconds; Click y; Type 'abc'; Click Z". My experience with unit testing tells me that as tests break 'randomly' (because something occasionally takes a few milliseconds too long to load) those delays get inserted, and eventually you end up with slow tests that are harder to maintain and still flaky.
In my project, we were installing on a variety of OSes and versions, and based on what dependencies had to be downloaded+installed it could take anywhere from a few seconds to a couple minutes. I ended up writing a lot of helper functions like `WaitForFile(filename, absoluteTimeout)` that basically run a retry loop, checking every couple seconds (to allow fast-as-possible pass/fail), but frankly was surprised that this was non-standard -- I kind of expected any "integration test assertion library" to be chock full of helpers like this.
I think there's a lot of ground to be covered in improving integration testing in general, and especially bringing in some more modern software design and engineering principles. Unit and integration tests are still code after all -- just because it doesn't ship with the product doesn't mean it shouldn't be maintained at the same quality.
- danidiaz 7y ago> WaitForFile(filename, absoluteTimeout) The Java bindings have support for this in the form of FluentWait#until http://javadox.com/org.seleniumhq.selenium/selenium-support/2.53.0/org/openqa/selenium/support/ui/FluentWait.html#until-com.google.common.base.Function- http://javadox.com/org.seleniumhq.selenium/selenium-support/... Using explicit waits for expected conditions (instead of static waits or implicit waits) helps with making the tests more robust. It's a bit more work though.
- plorntus 7y agoCypress is pretty good for this. Every command is queued up and sort of deferred. You write tests in a synchronous manner and it has retrryability built in so it will wait for an assertion to be truth before continuing (with a max timeout ofc). It's been working pretty well for me so far.
- opless 7y agoWait for five seconds? That's the first mistake. You should always wait for some kind of state change, you're just building in fragility.
- ethbro 7y agoThis. If your framework only does timing through pausing, find a new framework. That's 20 years out of date.