Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html logger #2103

Merged
merged 24 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
348fe08
First draft for the Html Logger.
Jul 29, 2019
56091eb
Adding the Program.cs for making the unit tests project build
Jul 29, 2019
a5fe993
1. Added docs for methods
Jul 30, 2019
0ed9a7e
Html logger acceptance Test added
Aug 8, 2019
385edf5
Merge remote-tracking branch 'upstream/master' into HtmlLogger
Aug 8, 2019
29aed06
incresed the file count in Tesplatform.portable and Testplatform nusp…
Aug 9, 2019
49ee322
Adding xlf files
Aug 9, 2019
e34d3df
Added installing dotnet-cli in build
Aug 9, 2019
203a717
Corrected defaultParamter:Logfile on HtmlLoggerTests
Aug 9, 2019
62011ee
Changed the hardcoded folder name of testresults
Aug 9, 2019
ff3d43d
Html.xslt is added to dll
Aug 12, 2019
ed1fdc9
Changed the file name html.xslt to Html.xslt and Added styling in xslt
Aug 13, 2019
b29505c
TestResults changed to TestRunDetails and summary comments corrected
Aug 13, 2019
35fcc2a
Added clickability and added test run duration and passing percentage
Aug 14, 2019
7fdf5e4
redundant code in xslt is removed and acceptanece test is corrected
Aug 19, 2019
df250ee
added failed results
Aug 22, 2019
6b81048
code refactoring using resharper
Aug 23, 2019
fef0cae
Merge branch 'master' into HtmlLogger
hvinett Aug 26, 2019
4b0a936
Fixed the xslt issues and added comments.\
Aug 26, 2019
b5e26c8
Merge from master
Aug 26, 2019
c48eca1
Merge branch 'HtmlLogger' of https://github.com/hvinett/vstest into H…
Aug 26, 2019
93467b2
unit tests refactored
Aug 27, 2019
35067d6
friend.cs added
Aug 27, 2019
14e82ee
Days in GetFormattedDurationString is fixed
Aug 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions TestPlatform.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244
# Visual Studio 15
VisualStudioVersion = 15.0.28307.779
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED0C35EB-7F31-4841-A24F-8EB708FFA959}"
EndProject
Expand Down Expand Up @@ -42,6 +42,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Integration", "Integration", "{46250E12-4CF1-4051-B4A7-80C8C06E0068}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logger", "Logger", "{020E15EA-731F-4667-95AF-226671E0C3AE}"
ProjectSection(SolutionItems) = preProject
test\Microsoft.TestPlatform.AcceptanceTests\TestResults.html = test\Microsoft.TestPlatform.AcceptanceTests\TestResults.html
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Performance", "Performance", "{595BE9C1-E10F-4E50-938A-E6C248D3F950}"
EndProject
Expand Down Expand Up @@ -172,6 +175,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingsMigrator.UnitTests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscoveryTestProject", "test\TestAssets\DiscoveryTestProject\DiscoveryTestProject.csproj", "{D16ACC60-52F8-4912-8870-5733A9F6852D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Extensions.HtmlLogger", "src\Microsoft.TestPlatform.Extensions.HtmlLogger\Microsoft.TestPlatform.Extensions.HtmlLogger.csproj", "{236A71E3-01DA-4679-9DFF-16A8E079ACFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests", "test\Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests\Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests.csproj", "{41248B96-6E15-4E5E-A78F-859897676814}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -866,6 +873,30 @@ Global
{D16ACC60-52F8-4912-8870-5733A9F6852D}.Release|x64.Build.0 = Release|Any CPU
{D16ACC60-52F8-4912-8870-5733A9F6852D}.Release|x86.ActiveCfg = Release|Any CPU
{D16ACC60-52F8-4912-8870-5733A9F6852D}.Release|x86.Build.0 = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|x64.ActiveCfg = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|x64.Build.0 = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|x86.ActiveCfg = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Debug|x86.Build.0 = Debug|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|Any CPU.Build.0 = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|x64.ActiveCfg = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|x64.Build.0 = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|x86.ActiveCfg = Release|Any CPU
{236A71E3-01DA-4679-9DFF-16A8E079ACFF}.Release|x86.Build.0 = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|x64.ActiveCfg = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|x64.Build.0 = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|x86.ActiveCfg = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Debug|x86.Build.0 = Debug|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|Any CPU.Build.0 = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x64.ActiveCfg = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x64.Build.0 = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x86.ActiveCfg = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -940,6 +971,8 @@ Global
{69F5FF81-5615-4F06-B83C-FCF979BB84CA} = {ED0C35EB-7F31-4841-A24F-8EB708FFA959}
{E7D4921C-F12D-4E1C-85AC-8B7F91C59B0E} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
{D16ACC60-52F8-4912-8870-5733A9F6852D} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{236A71E3-01DA-4679-9DFF-16A8E079ACFF} = {5E7F18A8-F843-4C8A-AB02-4C7D9205C6CF}
{41248B96-6E15-4E5E-A78F-859897676814} = {020E15EA-731F-4667-95AF-226671E0C3AE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0541B30C-FF51-4E28-B172-83F5F3934BCD}
Expand Down
8 changes: 5 additions & 3 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ function Publish-Package

# If there are some dependencies for the logger assemblies, those need to be moved too.
# Ideally we should just be publishing the loggers to the Extensions folder.
$loggers = @("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb")
$loggers = @("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb", "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.dll", "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.pdb")
foreach($file in $loggers) {
Write-Verbose "Move-Item $fullCLRPackageDir\$file $fullCLRExtensionsDir -Force"
Move-Item $fullCLRPackageDir\$file $fullCLRExtensionsDir -Force
Expand All @@ -307,10 +307,12 @@ function Publish-Package
Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force
}

# Move trx logger resource dlls
# Move logger resource dlls
if($TPB_LocalizedBuild) {
Move-Loc-Files $fullCLRPackageDir $fullCLRExtensionsDir "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.resources.dll"
Move-Loc-Files $coreCLR20PackageDir $coreCLRExtensionsDir "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.resources.dll"
Move-Loc-Files $fullCLRPackageDir $fullCLRExtensionsDir "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.resources.dll"
Move-Loc-Files $coreCLR20PackageDir $coreCLRExtensionsDir "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.resources.dll"
}

# Copy Blame Datacollector to Extensions folder.
Expand Down Expand Up @@ -354,7 +356,7 @@ function Publish-Package
}

# Move TestHostRuntimeProvider resource dlls
if($TPB_LocalizedBuild) {
if ($TPB_LocalizedBuild) {
Move-Loc-Files $fullCLRPackageDir $fullCLRExtensionsDir "Microsoft.TestPlatform.TestHostRuntimeProvider.resources.dll"
Move-Loc-Files $coreCLR20PackageDir $coreCLRExtensionsDir "Microsoft.TestPlatform.TestHostRuntimeProvider.resources.dll"
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function publish_package()

# Note Note: If there are some dependencies for the logger assemblies, those need to be moved too.
# Ideally we should just be publishing the loggers to the Extensions folder.
loggers=("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll" "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb")
loggers=("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll" "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb" "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.dll" "Microsoft.VisualStudio.TestPlatform.Extensions.Html.TestLogger.pdb")
for i in ${loggers[@]}; do
mv $packageDir/${i} $extensionsDir
done
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/TestPlatform.Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<!-- Name of the elements must be in sync with test\Microsoft.TestPlatform.TestUtilities\IntegrationTestBase.cs -->
<NETTestSdkPreviousVersion>15.5.0</NETTestSdkPreviousVersion>

<MSTestFrameworkVersion>1.3.1</MSTestFrameworkVersion>
<MSTestAdapterVersion>1.3.1</MSTestAdapterVersion>
<MSTestFrameworkVersion>1.4.0</MSTestFrameworkVersion>
<MSTestAdapterVersion>1.4.0</MSTestAdapterVersion>
<MSTestAssertExtensionVersion>1.0.3-preview</MSTestAssertExtensionVersion>

<XUnitFrameworkVersion>2.3.1</XUnitFrameworkVersion>
Expand Down
8 changes: 5 additions & 3 deletions scripts/build/TestPlatform.Localization.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
</ItemGroup>

<Target Name="Localize" Condition="'$(ProductProject)' == 'true' and @(EmbeddedResource) != ''" DependsOnTargets="_CreateLocalizeXLF;_CreateLocalizeResx" />
<!--<Message Importance="High" Text="resources are @(EmbeddedResource)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be changed.

</Target>-->

<Target Name="_CreateLocalizeXLF">
<Message Importance="High" Text="Create localized xlf for '$(AssemblyName)'" />
Expand All @@ -37,10 +39,10 @@
</CreateItem>

<!-- Create language based xlf files -->
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(LocResourceFile.Identity) -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf" Condition="%(LocResourceFile.Filename) != 'DefaultCodeCoverageConfig'"/>
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(LocResourceFile.Identity) -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf" Condition="%(LocResourceFile.Filename) != 'DefaultCodeCoverageConfig' and %(LocResourceFile.Filename) != 'html'"/>

<!-- Create neutral xlf -->
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(EmbeddedResource.Identity) -Xlf $(ResourceDirectory)\xlf\%(EmbeddedResource.Filename).xlf" Condition="%(EmbeddedResource.Filename) != 'DefaultCodeCoverageConfig'"/>
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe update -Resx %(EmbeddedResource.Identity) -Xlf $(ResourceDirectory)\xlf\%(EmbeddedResource.Filename).xlf" Condition="%(EmbeddedResource.Filename) != 'DefaultCodeCoverageConfig' and %(EmbeddedResource.Filename) != 'html'"/>
</Target>

<Target Name="_CreateLocalizeResx">
Expand All @@ -50,7 +52,7 @@
</CreateItem>

<!-- Convert language specific xlf files to resx -->
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe writeTarget -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf -Resx $(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx -verbose" Condition="%(LocResourceFile.Filename) != 'DefaultCodeCoverageConfig'"/>
<Exec Command="$(TestPlatformPackageDir)fmdev.xlftool\0.1.3\tools\xlftool.exe writeTarget -Xlf $(ResourceDirectory)\xlf\%(LocResourceFile.Filename).%(LocResourceFile.Language).xlf -Resx $(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx -verbose" Condition="%(LocResourceFile.Filename) != 'DefaultCodeCoverageConfig' and %(LocResourceFile.Filename) != 'html'"/>
<ItemGroup>
<EmbeddedResource Include="$(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ function Verify-Nuget-Packages($packageDirectory)
Write-Log "Starting Verify-Nuget-Packages."
$expectedNumOfFiles = @{"Microsoft.CodeCoverage" = 29;
"Microsoft.NET.Test.Sdk" = 13;
"Microsoft.TestPlatform" = 423;
"Microsoft.TestPlatform" = 437;
"Microsoft.TestPlatform.Build" = 19;
"Microsoft.TestPlatform.CLI" = 303;
"Microsoft.TestPlatform.CLI" = 317;
"Microsoft.TestPlatform.Extensions.TrxLogger" = 33;
"Microsoft.TestPlatform.ObjectModel" = 62;
"Microsoft.TestPlatform.Portable" = 474;
"Microsoft.TestPlatform.Portable" = 502;
"Microsoft.TestPlatform.TestHost" = 140;
"Microsoft.TestPlatform.TranslationLayer" = 121}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
</ItemGroup>
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" />
</Project>

Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,11 @@ public string[] GetFiles(string path, string searchPattern, SearchOption searchO
{
return Directory.GetFiles(path, searchPattern, searchOption);
}

/// <inheritdoc/>
public void Delete(string path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to TryDelete with bool return, In case file does not exists this API will throw.

{
File.Delete(path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,11 @@ public interface IFileHelper
/// <param name="searchOption">Search option</param>
/// <returns>string[]</returns>
string[] GetFiles(string path, string searchPattern, SearchOption searchOption);

/// <summary>
/// Deletes the specified file
/// </summary>
/// <param name="path"></param>
void Delete(string path);
}
}
62 changes: 62 additions & 0 deletions src/Microsoft.TestPlatform.Extensions.HtmlLogger/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger
{
using System;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

public static class Constants
{
/// <summary>
/// Uri used to uniquely identify the Html logger.
/// </summary>
public const string ExtensionUri = "logger://Microsoft/TestPlatform/HtmlLogger/v1";

/// <summary>
/// Alternate user friendly string to uniquely identify the console logger.
/// </summary>
public const string FriendlyName = "Html";

/// <summary>
/// The file extension of xml file
/// </summary>
public const string XmlFileExtension = "xml";

/// <summary>
/// The file extension of html file
/// </summary>
public const string HtmlFileExtension = "html";

/// /// <summary>
/// Property Id storing the TestType.
/// </summary>
public const string TestTypePropertyIdentifier = "TestType";

/// <summary>
/// Ordered test type guid
/// </summary>
public static readonly Guid OrderedTestTypeGuid = new Guid("ec4800e8-40e5-4ab3-8510-b8bf29b1904d");

/// <summary>
/// Property Id storing the ParentExecutionId.
/// </summary>
public const string ParentExecutionIdPropertyIdentifier = "ParentExecId";

/// <summary>
/// Property Id storing the ExecutionId.
/// </summary>
public const string ExecutionIdPropertyIdentifier = "ExecutionId";

/// <summary>
/// Log file parameter key
/// </summary>
public const string LogFileNameKey = "LogFileName";

public static readonly TestProperty ExecutionIdProperty = TestProperty.Register("ExecutionId", ExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult));

public static readonly TestProperty ParentExecIdProperty = TestProperty.Register("ParentExecId", ParentExecutionIdPropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult));

public static readonly TestProperty TestTypeProperty = TestProperty.Register("TestType", TestTypePropertyIdentifier, typeof(Guid), TestPropertyAttributes.Hidden, typeof(TestResult));
}
}
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Extensions.HtmlLogger/Friends.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Runtime.CompilerServices;

#region Test Assemblies

[assembly: InternalsVisibleTo("Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]

#endregion
Loading