in src/Microsoft.VisualStudio.Extensibility.Testing.Xunit.Shared/Threading/InProcessIdeTestInvoker.cs [99:142]
protected override Task BeforeTestMethodInvokedAsync()
{
foreach (var beforeAfterAttribute in _beforeAfterAttributes)
{
var attributeName = beforeAfterAttribute.GetType().Name;
if (!MessageBus.QueueMessage(new BeforeTestStarting(Test, attributeName)))
{
CancellationTokenSource.Cancel();
}
else
{
try
{
Timer.Aggregate(() => beforeAfterAttribute.Before(TestMethod));
_beforeAfterAttributesRun.Push(beforeAfterAttribute);
}
catch (Exception ex) when (DataCollectionService.LogAndCatch(ex))
{
Aggregator.Add(ex);
break;
}
finally
{
if (!MessageBus.QueueMessage(new BeforeTestFinished(Test, attributeName)))
{
CancellationTokenSource.Cancel();
}
}
}
if (CancellationTokenSource.IsCancellationRequested)
{
break;
}
}
#if NET472
return Task.CompletedTask;
#else
var tcs = new TaskCompletionSource<bool>();
tcs.SetResult(true);
return tcs.Task;
#endif
}