Blame for vstest#915
Conversation
This feature gets the faulty test case name in event of a test host crash of reason unknown. There are various scenarios in which the test host crashes due to a faulty test case and the reason cannot be diagnosed. This pull request gets the name of the test case which caused the crash and displays it on the console. To enable the blame mode, use --Blame|/Blame
|
@vagisha-nidhi, |
| Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force | ||
| } | ||
|
|
||
| # Publish Datacollector |
There was a problem hiding this comment.
Should this assembly be added for signing?
| @@ -0,0 +1,147 @@ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
There was a problem hiding this comment.
nit: is there a naming convention for extensions? TrxLogger is named as Microsoft.TestPlatform.Extensions.TrxLogger, should we follow M.TP.E.Blame?
| @@ -0,0 +1,58 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <AssemblyName>Microsoft.TestPlatform.BlameDataCollector</AssemblyName> | ||
| <TargetFrameworks>netcoreapp1.0;netcoreapp2.0;net46</TargetFrameworks> |
There was a problem hiding this comment.
Why not build for netstandard only?
| <PropertyGroup> | ||
| <AssemblyName>Microsoft.TestPlatform.BlameDataCollector</AssemblyName> | ||
| <TargetFrameworks>netcoreapp1.0;netcoreapp2.0;net46</TargetFrameworks> | ||
| <WarningsAsErrors>true</WarningsAsErrors> |
There was a problem hiding this comment.
Already used in testplatform.settings.targets?
| ValidateArg.NotNull<object>(sender, "sender"); | ||
| ValidateArg.NotNull<TestRunCompleteEventArgs>(e, "e"); | ||
|
|
||
| if (!e.IsAborted) return; |
There was a problem hiding this comment.
nit: please wrap if clauses in parenthesis.
| if (attachmentSet.DisplayName.Equals(Constants.BlameDataCollectorName)) | ||
| { | ||
| var filepath = attachmentSet.Attachments[0].Uri.LocalPath; | ||
| List<TestCase> testCaseList = this.blameReaderWriter.ReadTestSequence(filepath); |
There was a problem hiding this comment.
Can we use Enumerable.LastOrDefault?
| /// <summary> | ||
| /// Test run Abort | ||
| /// </summary> | ||
| public const string TestRunAbortReason = "The test run was aborted because the host process crashed unexpectedly while executing test "; |
|
|
||
| #region Test Assemblies | ||
|
|
||
| [assembly: InternalsVisibleTo("Microsoft.TestPlatform.BlameDataCollector.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] |
| } | ||
|
|
||
| [TestMethod] | ||
| public void TriggerTestCaseStartedHandlerShouldIncreaseTestStartCount() |
There was a problem hiding this comment.
This test is testing an internal implementation detail. We should care about the user behavior.
| // In case of crash testStartCount will be greater than testEndCount and we need to send write the sequence | ||
| if (this.testStartCount > this.testEndCount) | ||
| { | ||
| var filepath = Path.Combine(AppContext.BaseDirectory, Constants.AttachmentFileName); |
There was a problem hiding this comment.
Check filepath
| /// <summary> | ||
| /// Uri used to uniquely identify the Blame logger. | ||
| /// </summary> | ||
| public const string ExtensionUri = "logger://Microsoft/TestPlatform/Extensions/Blame"; |
| if (testCaseList.Count > 0) | ||
| { | ||
| var testcase = testCaseList[testCaseList.Count - 1]; | ||
| return testcase.FullyQualifiedName; |
There was a problem hiding this comment.
LastOrDefault
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" /> | ||
| <ProjectReference Include="..\..\src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
Enable stylecop
| <!-- NetCoreExtensions --> | ||
| <CoreAssembliesToSign Include="$(ArtifactsCoreDirectory)Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll" /> | ||
| <CoreAssembliesToSign Include="$(ArtifactsCoreDirectory)Extensions\Microsoft.TestPlatform.TestHostRuntimeProvider.dll" /> | ||
| <CoreAssembliesToSign Include="$(ArtifactsCoreDirectory)Extensions\Microsoft.TestPlatform.Extensions.BlameDataCollector.dll" /> |
There was a problem hiding this comment.
Add for net46
This feature gets the faulty test case name in event of a test host crash of reason unknown.
There are various scenarios in which the test host crashes due to a faulty test case and the reason cannot be diagnosed.
This pull request gets the name of the test case which caused the crash and displays it on the console.
To enable the blame mode, use --Blame|/Blame
The usage is as follows -
'''

"vstest.console.exe" /Testadapterpath:"C:\TestProject\TestProject\bin\Debug\net46" C:\path\to\your\assembly.dll /Blame
'''