fix for issue #8
This commit is contained in:
parent
14fbf8f7c7
commit
2b43b35598
4 changed files with 31 additions and 20 deletions
|
@ -10,7 +10,6 @@ namespace VitaliiGanzha.VsDingExtension
|
|||
using EnvDTE80;
|
||||
using Microsoft.VisualStudio.ComponentModelHost;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.TestWindow.Controller;
|
||||
using Microsoft.VisualStudio.TestWindow.Extensibility;
|
||||
using Task = System.Threading.Tasks.Task;
|
||||
|
||||
|
@ -161,16 +160,30 @@ namespace VitaliiGanzha.VsDingExtension
|
|||
{
|
||||
if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
|
||||
{
|
||||
var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
|
||||
var isTestsFailed = testOperation.DominantTestState == TestState.Failed;
|
||||
var eventType = isTestsFailed? EventType.TestsCompletedFailure : EventType.TestsCompletedSuccess;
|
||||
if (Options.IsBeepOnTestFailed && isTestsFailed)
|
||||
try
|
||||
{
|
||||
HandleEventSafe(eventType, "Test execution failed!", ToolTipIcon.Error);
|
||||
// Issue #8: VS 2015 stops working when looking at Test Manager Window #8
|
||||
// This extention can't take dependency on Microsoft.VisualStudio.TestWindow.Core.dll
|
||||
// Because it will crash VS 2015. But DominantTestState is defined in that assembly.
|
||||
// So as a workaround - cast it to dynamic (ewww, but alternative - to create new project/build and publish it separately.)
|
||||
var testOperation = (dynamic)(operationStateChangedEventArgs.Operation);
|
||||
var dominantTestState = (TestState)testOperation.DominantTestState;
|
||||
var isTestsFailed = dominantTestState == TestState.Failed;
|
||||
var eventType = isTestsFailed ? EventType.TestsCompletedFailure : EventType.TestsCompletedSuccess;
|
||||
if (Options.IsBeepOnTestFailed && isTestsFailed)
|
||||
{
|
||||
HandleEventSafe(eventType, "Test execution failed!", ToolTipIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleEventSafe(eventType, "Test execution has been completed.");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleEventSafe(eventType, "Test execution has been completed.");
|
||||
ActivityLog.LogError(GetType().FullName, ex.Message);
|
||||
// Unable to get dominate test status, beep default sound for test
|
||||
HandleEventSafe(EventType.TestsCompletedSuccess, "Test execution has been completed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue