0

我已经设置了本地 Visual Studio (VS2012) 以在构建后运行测试。可以,但是要查看测试结果,我必须手动打开 TestExplorer。当测试失败时,有没有办法自动打开 TestExplorer,或者在屏幕上显示一些东西,或者播放一些声音?

4

1 回答 1

0

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

你可以在这里找到我的扩展和源代码: https ://github.com/sboulema/vsdingextension

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

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
            ...
        }
    }
}
于 2015-12-16T15:16:37.843 回答