Reputation: 21
I have a few scala tests up and running but am confused as to how to close/quit webdriver upon completion of the run. I am aware of beforeAndAfterAll, but it seems that it acts on each test class whereas I only want to quit webdriver at the end (not inbetween each test & then restarting it). It doesn't appear to be doing anything, but here's what I've currently got:
class testRunHandler extends org.scalatest.Reporter{
import org.scalatest.events._
def apply(event: Event){
event match{
case _:RunCompleted => foo.driver.close()
case _ =>
}
}
I tried to follow this but wasn't sure how to apply it: Doing something before or after all Scalatest tests
Upvotes: 2
Views: 351
Reputation: 15520
You can use this:
sys.addShutdownHook { foo.driver.close() }
It's probably best if you make sure this line is only executed once. I've put in an object
, near where I configure the driver.
Upvotes: 1