class MockExiter extends Exiter {
var exitCode: Option[Int] = None
def exit(code: Int): Unit = {
exitCode = Some(code)
}
}
If you want to test the real thing, or if you can't change the signature of f, then I perhaps you can use the Java API for forking (in java.lang.Runtime). You'd need to fork off another process from your test, then wait for it to complete, then look at its status. It wouldn't necessarily mean that *your* method did that, but you could check for that expected exit status. That's quite heavyweight to create another process, but you can do it.
Otherwise I think it is tough to capture whether or not something exited. Anyone else have any other ideas?
Bill