Add option to only notify on failed tests

This commit is contained in:
Samir L. Boulema 2015-12-16 16:04:33 +01:00
parent 801a83bcbc
commit 610f82311d
7 changed files with 43 additions and 11 deletions

1
.gitignore vendored
View File

@ -155,3 +155,4 @@ $RECYCLE.BIN/
# Mac desktop service store files
.DS_Store
/VsDingExtensionProject/pingme.txt
/VsDingExtensionProject/*.csdat

View File

@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BD9D4DB-8683-4698-8D24-01EE7306F73A}"
ProjectSection(SolutionItems) = preProject
IntegrationTests.testsettings = IntegrationTests.testsettings

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<FileUpgradeFlags>
@ -56,6 +56,9 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.11.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />

View File

@ -22,7 +22,12 @@ namespace VitaliiGanzha.VsDingExtension
[Category("Beeps")]
[DisplayName("Tests")]
[Description("Beep when a test run is completed")]
public bool IsBuildOnTestComplete { get; set; }
public bool IsBeepOnTestComplete { get; set; }
[Category("Beeps")]
[DisplayName("Failed Tests")]
[Description("Beep only when a test failed")]
public bool IsBeepOnTestFailed { get; set; }
[DisplayName("Only when in background")]
[Description("Beep only when Visual Studio does not have focus")]
@ -36,7 +41,8 @@ namespace VitaliiGanzha.VsDingExtension
{
IsBeepOnBreakpointHit = true;
IsBeepOnBuildComplete = true;
IsBuildOnTestComplete = true;
IsBeepOnTestComplete = true;
IsBeepOnTestFailed = false;
ShowTrayNotifications = true;
IsBeepOnlyWhenVisualStudioIsInBackground = false;
}

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.

View File

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>12.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>speaker.ico</ApplicationIcon>
@ -58,6 +63,9 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0">
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
</Reference>

View File

@ -15,9 +15,10 @@
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TestWindow.Extensibility;
using Microsoft.VisualStudio.TestWindow.Controller;
using Process = System.Diagnostics.Process;
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)]
[Guid(GuidList.guidVsDingExtensionProjectPkgString)]
@ -67,7 +68,7 @@
}
};
debugEvents.OnEnterBreakMode += delegate(dbgEventReason reason, ref dbgExecutionAction action)
debugEvents.OnEnterBreakMode += delegate (dbgEventReason reason, ref dbgExecutionAction action)
{
if (reason != dbgEventReason.dbgEventReasonStep && Options.IsBeepOnBreakpointHit)
{
@ -163,9 +164,20 @@
private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{
if (Options.IsBuildOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
if (Options.IsBeepOnTestFailed)
{
var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
if (testOperation.DominantTestState == TestState.Failed)
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution failed!");
}
}
else
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
}
}
}
#endregion
@ -180,7 +192,7 @@
var procId = Process.GetCurrentProcess().Id;
int activeProcId;
GetWindowThreadProcessId(activatedHandle, out activeProcId);
return activeProcId == procId;
return activeProcId == procId;
}
public void Dispose()