Unit testing 如何在VisualStudio中获得单元测试失败的通知?

Unit testing 如何在VisualStudio中获得单元测试失败的通知?,unit-testing,visual-studio-2012,test-explorer,Unit Testing,Visual Studio 2012,Test Explorer,我已经设置了本地Visual Studio(VS2012),以便在生成后运行测试。这可以正常工作,但是要查看测试结果,我必须手动打开TestExplorer。当测试失败时,是否有办法自动打开TestExplorer,或在屏幕上显示一些内容,或播放一些声音?正在寻找相同的功能,但找不到它。扩展接近的现有VS扩展 您可以在此处找到我的扩展名和源代码: 有关如何检查测试结果的代码片段: protected override void Initialize() { ... var o

我已经设置了本地Visual Studio(VS2012),以便在生成后运行测试。这可以正常工作,但是要查看测试结果,我必须手动打开TestExplorer。当测试失败时,是否有办法自动打开TestExplorer,或在屏幕上显示一些内容,或播放一些声音?

正在寻找相同的功能,但找不到它。扩展接近的现有VS扩展

您可以在此处找到我的扩展名和源代码:

有关如何检查测试结果的代码片段:

protected override void Initialize()
{
    ...

    var operationState = componentModel.GetService<IOperationState>();
    operationState.StateChanged += OperationStateOnStateChanged;
}

private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{
    if (operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
    {
        var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
        if (testOperation.DominantTestState == TestState.Failed)
        {
            // Test failed, show a notification
            ...
        }
    }
}
受保护的覆盖无效初始化()
{
...
var operationState=componentModel.GetService();
operationState.StateChanged+=OperationStateOnStateChanged;
}
私有void操作StateonStateChanged(对象发送方,操作StateChangeDeventargs操作StateChangeDeventargs)
{
if(operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
var testOperation=((TestRunRequest)operationStateChangedEventArgs.Operation);
if(testOperation.DominantTestState==TestState.Failed)
{
//测试失败,显示通知
...
}
}
}

您至少可以在这里描述一下您的方法吗?添加了关于如何获得文本执行结果的代码