Skip to content

Commit

Permalink
feat: port xunit and nunit loggers into testlogger repo. (#68)
Browse files Browse the repository at this point in the history
* feat: port xunit and nunit loggers into testlogger repo.

* chore: add new tests to CI

* fix: revert preview feature usage.

* chore: create nuget package for loggers.
  • Loading branch information
codito authored Jun 17, 2024
1 parent 6249398 commit 677c53f
Show file tree
Hide file tree
Showing 74 changed files with 3,909 additions and 103 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
APP_BUILD_VERSION: ${{ format('3.1.{0}', github.run_number) }}
APP_BUILD_VERSION: ${{ format('4.0.{0}', github.run_number) }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET 7.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: 8.x
- name: Setup .NET 3.1.x
uses: actions/setup-dotnet@v1
with:
Expand All @@ -29,9 +29,14 @@ jobs:
- name: Package (release)
run: dotnet pack -c Release -p:PackageVersion=${{ env.APP_BUILD_VERSION }}
- name: Unit test
run: dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/TestLogger.UnitTests/TestLogger.UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover
run: |
dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/TestLogger.UnitTests/TestLogger.UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover
dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/NUnit.Xml.TestLogger.UnitTests/NUnit.Xml.TestLogger.UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover
- name: Acceptance test
run: dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/TestLogger.AcceptanceTests/TestLogger.AcceptanceTests.csproj
run: |
dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/TestLogger.AcceptanceTests/TestLogger.AcceptanceTests.csproj
dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/Xunit.Xml.TestLogger.AcceptanceTests/Xunit.Xml.TestLogger.AcceptanceTests.csproj
dotnet test -p:PackageVersion=${{ env.APP_BUILD_VERSION }} test/NUnit.Xml.TestLogger.AcceptanceTests/NUnit.Xml.TestLogger.AcceptanceTests.csproj
- name: Upload Verification Files on Fail
if: ${{ failure() }}
uses: actions/upload-artifact@v2
Expand All @@ -48,5 +53,6 @@ jobs:
- name: Publish packages
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' }}
run: |
dotnet nuget push 'src/TestLogger/bin/Release/*.nupkg' --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/spekt/index.json
dotnet nuget push 'src/TestLogger/bin/Release/*.nupkg' --api-key ${{ secrets.SPEKT_MYGET_KEY }} --source https://www.myget.org/F/spekt/api/v3/index.json
dotnet nuget push 'src/Xunit.Xml.Package/bin/Release/*.nupkg' --api-key ${{ secrets.SPEKT_MYGET_KEY }} --source https://www.myget.org/F/spekt/api/v3/index.json
dotnet nuget push 'src/NUnit.Xml.Package/bin/Release/*.nupkg' --api-key ${{ secrets.SPEKT_MYGET_KEY }} --source https://www.myget.org/F/spekt/api/v3/index.json
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bld/
[Ll]og/

# Test results
**/test-results.xml
**/*test-results.xml
**/test-results.json

# Visual Studio 2015/2017 cache/options directory
Expand Down Expand Up @@ -335,6 +335,9 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# VSTest logs
log*.txt

.vscode/settings.json

*.received.txt
15 changes: 15 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<!-- Test Assets use the minimum supported versions -->
<NETTestSdkMinimumVersion>16.5.0</NETTestSdkMinimumVersion>
<XunitVersion>2.3.1</XunitVersion>
<XunitTestAdapterVersion>2.3.1</XunitTestAdapterVersion>
<NUnitVersion>3.13.2</NUnitVersion>
<NUnitTestAdapterVersion>4.0.0</NUnitTestAdapterVersion>
<MSTestVersion>3.4.3</MSTestVersion>

<!-- Only use stable versions of stylecop -->
<StylecopVersion>1.1.118</StylecopVersion>
</PropertyGroup>
</Project>
<!-- vim: set ft=xml : -->
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ForEach ($local in $($locals -split "`r`n"))
{
$local = $local.Substring($local.IndexOf(":") + 2)
"Deleting from $local"
dotnet nuget delete Json.TestLogger 3.1.0-dev --force-english-output --non-interactive -s $local
dotnet nuget delete Json.TestLogger 4.0.0-dev --force-english-output --non-interactive -s $local
}

Remove-Item .\test\package\bin\ -Recurse
Expand Down
5 changes: 4 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

dotnet pack &&\
dotnet test test/TestLogger.UnitTests/TestLogger.UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover &&\
dotnet test test/TestLogger.AcceptanceTests/TestLogger.AcceptanceTests.csproj
dotnet test test/NUnit.Xml.TestLogger.UnitTests/NUnit.Xml.TestLogger.UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover &&\
dotnet test test/TestLogger.AcceptanceTests/TestLogger.AcceptanceTests.csproj &&\
dotnet test test/Xunit.Xml.TestLogger.AcceptanceTests/Xunit.Xml.TestLogger.AcceptanceTests.csproj &&\
dotnet test test/NUnit.Xml.TestLogger.AcceptanceTests/NUnit.Xml.TestLogger.AcceptanceTests.csproj
20 changes: 0 additions & 20 deletions scripts/dependencies.props

This file was deleted.

24 changes: 1 addition & 23 deletions scripts/settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SourceRoot Condition="$(SourceRoot) == ''">$(MSBuildThisFileDirectory)../../</SourceRoot>
<SourcePrefix>3.1.0</SourcePrefix>
<SourcePrefix>4.0.0</SourcePrefix>
</PropertyGroup>
<PropertyGroup>
<!-- Versioning is defined from the build script. Use a default dev build if it's not defined.
Expand Down Expand Up @@ -39,8 +39,6 @@
<DefineConstants>$(DefineConstants);CODE_ANALYSIS</DefineConstants>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)dependencies.props" />

<!-- Common dependencies for all projects -->
<ItemGroup>
<AdditionalFiles Include="$(SourceRoot)scripts\stylecop.json">
Expand All @@ -52,26 +50,6 @@
</PackageReference>
</ItemGroup>

<!-- Test project settings -->
<Choose>
<When Condition="$(TestProject) == 'true'">
<ItemGroup>
<PackageReference Include="MSTest.TestFramework">
<Version>$(MSTestVersion)</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>$(MSTestVersion)</Version>
</PackageReference>
<PackageReference Include="Moq">
<Version>$(MoqVersion)</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>$(NETTestSdkVersion)</Version>
</PackageReference>
</ItemGroup>
</When>
</Choose>

<!-- Code analysis settings -->
<PropertyGroup>
<CodeAnalysisRuleSet>$(SourceRoot)scripts/stylecop.ruleset</CodeAnalysisRuleSet>
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<PackageVersion Condition="'$(PackageVersion)' == ''">3.1.0-dev</PackageVersion>
<PackageVersion Condition="'$(PackageVersion)' == ''">4.0.0-dev</PackageVersion>
</PropertyGroup>
</Project>
<!-- vi: set ft=xml: -->
63 changes: 63 additions & 0 deletions src/NUnit.Xml.Package/NUnit.Xml.Package.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<SourceRoot Condition="$(SourceRoot) == ''">..\..\</SourceRoot>
</PropertyGroup>
<Import Project="$(SourceRoot)scripts/settings.targets" />

<PropertyGroup>
<TargetFramework>netstandard1.5</TargetFramework>
<Version>$(PackageVersion)</Version>
<AssemblyName>NUnitXml.TestLogger</AssemblyName>

<!-- This isn't an assembly -->
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>

<!-- Don't create outputs during build or publish -->
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
<CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<!-- Disable warning that there are no source files. It is intentional. -->
<NoWarn>$(NoWarn);2008;NU5127</NoWarn>

<!-- Nuget pack configuration -->
<NuspecFile>bin\$(Configuration)\$(TargetFramework)\NUnitXml.TestLogger.nuspec</NuspecFile>
<NuspecProperties>version=$(Version)</NuspecProperties>
<IncludeContentInPack>false</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageIcon>packageIcon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NUnit.Xml.TestLogger\NUnit.Xml.TestLogger.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="NUnitXml.TestLogger.props">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="NUnitXml.TestLogger.nuspec">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Update="packageIcon.png" Pack="true" PackagePath="">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<!-- Prevent Csc from being called -->
<Target Name="CoreCompile" />
</Project>
25 changes: 25 additions & 0 deletions src/NUnit.Xml.Package/NUnitXml.TestLogger.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>NunitXml.TestLogger</id>
<version>$version$</version>
<title>NunitXml.TestLogger</title>
<authors>spekt</authors>
<owners>spekt</owners>
<projectUrl>https://github.com/spekt/nunit.testlogger</projectUrl>
<description>Xml logger for NUnit v3 compliant xml report when test is running with "dotnet test" or "dotnet vstest".</description>
<license type="expression">MIT</license>
<icon>packageIcon.png</icon>
</metadata>
<files>
<file src="Microsoft.VisualStudio.TestPlatform.Extension.Nunit.Xml.TestLogger.dll" target="build\_common\" />
<file src="Spekt.TestLogger.dll" target="build\_common\" />
<file src="packageIcon.png" target="\" />

<!-- Net Core -->
<file src="NunitXml.TestLogger.props" target="build\netstandard1.0\" />

<!-- Desktop -->
<file src="NunitXml.TestLogger.props" target="build\net45\" />
</files>
</package>
15 changes: 15 additions & 0 deletions src/NUnit.Xml.Package/NUnitXml.TestLogger.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)..\_common\Microsoft.VisualStudio.TestPlatform.Extension.NUnit.Xml.TestLogger.dll">
<Link>Microsoft.VisualStudio.TestPlatform.Extension.NUnit.Xml.TestLogger.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\_common\Spekt.TestLogger.dll">
<Link>Spekt.TestLogger.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Project>
Binary file added src/NUnit.Xml.Package/packageIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/NUnit.Xml.TestLogger/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Spekt Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

// <auto-generated>
// Skip code analysis errors.
// </auto-generated>

using System.Diagnostics.CodeAnalysis;

[assembly: ExcludeFromCodeCoverage]

namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
internal sealed class ExcludeFromCodeCoverageAttribute : Attribute { }
}
26 changes: 26 additions & 0 deletions src/NUnit.Xml.TestLogger/NUnit.Xml.TestLogger.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SourceRoot Condition="$(SourceRoot) == ''">..\..\</SourceRoot>
</PropertyGroup>
<Import Project="$(SourceRoot)scripts/settings.targets" />

<PropertyGroup>
<TargetFramework>netstandard1.5</TargetFramework>
<AssemblyName>Microsoft.VisualStudio.TestPlatform.Extension.NUnit.Xml.TestLogger</AssemblyName>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Label="Configuration">
<RootNamespace>Microsoft.VisualStudio.TestPlatform.Extension.NUnit.Xml.TestLogger</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../TestLogger/TestLogger.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit 677c53f

Please sign in to comment.