Custom execution test started event #305
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Most custom
IExecution
implementations will make use of the built-in convenience methodtest.Run(...)
, which emits a Test Started event and naturally handles any exceptions thrown by the test method in order to unambiguously emit a Pass or Fail result. This keeps the semantics of test running natural, while letting custom execution authors avoid littering their code with excessive exception handling.However, some custom execution implementations need to take much more fine grained control over the testing lifecycle. For instance:
ExpectedException
will want to let a test method throw, catch the exception, and evaluate whether or not the exception should be treated as a Pass or Fail result.In either case, such a user might want to start with a custom
IExecution
that perfectly mirrors the built-intest.Run(...)
behavior, and then further customize from there. Instead of callingtest.Run(...)
, which handles exceptions and emits Pass or Fail, they would want to call the method directly while allowing for exceptions:test.Method.Call(...)
. Since they'd no longer be callingtest.Run(...)
, they'd instead call the specific event emitting methods explicitly. Prior to this PR, the best you could do is the following:Since the user had no way to emit the Test Started event, IDE runs have no opportunity to display a spinner or similar indicator on long-running tests. If you have a long-running test, you would get no visual indicator of which test was running slowly.
test.Run(...)
naturally emits the Test Started event, but since we are callingtest.Method.Call(...)
instead, we naturally miss out on it just like we miss out on automatic Pass and Fail events. A user taking control like this would prefer to take full control.This PR adds the simple ability to emit Test Started events, useful in such high-customization
IExecution
scenarios:(Thanks to @Suremaker for discovering the missed IDE 'spinner' behavior and for diagnosing it so clearly during our discussion on #57.)