run<R> method
Starts a context, passes it to body, closes it with close() when
body returns, and returns what body returned.
A context that failed to start is passed too, instead of throwing:
check it with hasFailed() or
AssertableApplicationContext.startupFailure. For a body that
awaits, use runAsync; here the context would be closed at the first
await.
Implementation
R run<R>(R Function(AssertableApplicationContext context) body) {
final assertable = _start();
try {
return body(assertable);
} finally {
assertable._close();
}
}