spek icon indicating copy to clipboard operation
spek copied to clipboard

Code in 'beforeGroup' and 'it' runs on different threads that causes unavailabylity to use some test frameworks (e.g. Selenide)

Open alexei-ya opened this issue 6 years ago • 2 comments

Currently code in 'beforeGroup' runs on the main thread, but code in 'it' after 2.0.3 version on DefaultDispatcher-worker's thread. For example this situstion causes unavailability to use Selenide framework in such scenario:

  • Open url in 'before'
  • Do assertions in 'it'

This happens because of binding of WebDriver when it is created to current thread(main) in 'before' and unavailability to find WebDriver in 'it' (DefaultDispatcher).

It is possible (or will be some-when) to execute code in before*, it, after* on the same thread or i need to dig in some another way? Thanks in advance!

alexei-ya avatar Oct 08 '19 13:10 alexei-ya

I'm planning to use coroutines more and at the moment usages of it is internal - beforeGroup will eventually be executed via coroutines as well. I might be able to provide a way (an API) to control the dispatcher used to run the test, which will probably fix your issue.

raniejade avatar Oct 10 '19 08:10 raniejade

Hi. Thanks for the answer. Yeah, such API would be great to workaround such situations.

alexei-ya avatar Oct 10 '19 10:10 alexei-ya