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

feat: xUnit output project #372

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions PactNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\NuGet.targets = src\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PactNet.Output.Xunit", "src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj", "{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -255,6 +257,18 @@ Global
{16429FC0-67A5-4089-98A9-CBD72D9DB910}.Release|x64.Build.0 = Release|Any CPU
{16429FC0-67A5-4089-98A9-CBD72D9DB910}.Release|x86.ActiveCfg = Release|Any CPU
{16429FC0-67A5-4089-98A9-CBD72D9DB910}.Release|x86.Build.0 = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|x64.ActiveCfg = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|x64.Build.0 = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|x86.ActiveCfg = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Debug|x86.Build.0 = Debug|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|Any CPU.Build.0 = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|x64.ActiveCfg = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|x64.Build.0 = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|x86.ActiveCfg = Release|Any CPU
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -279,6 +293,7 @@ Global
{172916A7-5913-4389-8F58-A774036C9566} = {87FC5A4B-1977-4FBA-AA71-63F48B28C3B0}
{1CE30FC5-1439-4FB3-85ED-B2D4E70FB311} = {9BA1DB3F-BD05-4E6A-861F-E1FEE63DC76F}
{16429FC0-67A5-4089-98A9-CBD72D9DB910} = {9BA1DB3F-BD05-4E6A-861F-E1FEE63DC76F}
{02E265A1-A7A2-4106-8F6A-5027FDC3FC50} = {CF67D7A1-AE96-420B-9971-65E535B903E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2CBC30C-92D4-4E3A-A5B8-1E5D4E938DFC}
Expand Down
1 change: 1 addition & 0 deletions samples/EventApi/Consumer.Tests/Consumer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Consumer\Consumer.csproj" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion samples/EventApi/Consumer.Tests/EventsApiConsumerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Newtonsoft.Json.Serialization;
using PactNet;
using PactNet.Matchers;
using PactNet.Output.Xunit;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -28,7 +29,7 @@ public EventsApiConsumerTests(ITestOutputHelper output)
PactDir = "../../../pacts/",
Outputters = new[]
{
new XUnitOutput(output)
new XunitOutput(output)
},
DefaultJsonSettings = new JsonSerializerSettings
{
Expand Down
20 changes: 0 additions & 20 deletions samples/EventApi/Consumer.Tests/XUnitOutput.cs

This file was deleted.

3 changes: 2 additions & 1 deletion samples/EventApi/Provider.Tests/EventAPITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using PactNet;
using PactNet.Infrastructure.Outputters;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -28,7 +29,7 @@ public void EnsureEventApiHonoursPactWithConsumer()
LogLevel = PactLogLevel.Information,
Outputters = new List<IOutput>
{
new XUnitOutput(this.output)
new XunitOutput(this.output)
}
};

Expand Down
1 change: 1 addition & 0 deletions samples/EventApi/Provider.Tests/Provider.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Provider\Provider.csproj" />
</ItemGroup>
Expand Down
20 changes: 0 additions & 20 deletions samples/EventApi/Provider.Tests/XUnitOutput.cs

This file was deleted.

1 change: 1 addition & 0 deletions samples/Messaging/Consumer.Tests/Consumer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Consumer\Consumer.csproj" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion samples/Messaging/Consumer.Tests/StockEventProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Newtonsoft.Json.Serialization;
using PactNet;
using PactNet.Matchers;
using PactNet.Output.Xunit;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -25,7 +26,7 @@ public StockEventProcessorTests(ITestOutputHelper output)
},
Outputters = new[]
{
new XUnitOutput(output)
new XunitOutput(output)
}
});

Expand Down
20 changes: 0 additions & 20 deletions samples/Messaging/Consumer.Tests/XUnitOutput.cs

This file was deleted.

1 change: 1 addition & 0 deletions samples/Messaging/Provider.Tests/Provider.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Provider\Provider.csproj" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion samples/Messaging/Provider.Tests/StockEventGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Newtonsoft.Json.Serialization;
using PactNet;
using PactNet.Infrastructure.Outputters;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using PactNet.Verifier.Messaging;
using Xunit;
Expand All @@ -25,7 +26,7 @@ public StockEventGeneratorTests(ITestOutputHelper output)
{
Outputters = new List<IOutput>
{
new XUnitOutput(output)
new XunitOutput(output)
},
LogLevel = PactLogLevel.Debug
});
Expand Down
20 changes: 0 additions & 20 deletions samples/Messaging/Provider.Tests/XUnitOutput.cs

This file was deleted.

1 change: 1 addition & 0 deletions samples/ReadMe/Provider.Tests/Readme.Provider.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\Provider\Readme.Provider.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion samples/ReadMe/Provider.Tests/SomethingApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using PactNet.Infrastructure.Outputters;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -31,7 +32,7 @@ public void EnsureSomethingApiHonoursPactWithConsumer()
// xUnit 2 does not capture the console output, so this
// sample creates a custom xUnit outputter. You will
// have to do the same in xUnit projects.
new XUnitOutput(output),
new XunitOutput(output),
},
};

Expand Down
20 changes: 0 additions & 20 deletions samples/ReadMe/Provider.Tests/XUnitOutput.cs

This file was deleted.

29 changes: 29 additions & 0 deletions src/PactNet.Output.Xunit/PactNet.Output.Xunit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591;NU5105</NoWarn>
<OutputType>Library</OutputType>
</PropertyGroup>

<Import Project="../NuGet.targets" />

<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<PackageReleaseNotes>
v1.0.0
- Initial release
</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PactNet.Abstractions\PactNet.Abstractions.csproj" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions src/PactNet.Output.Xunit/XunitOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using PactNet.Infrastructure.Outputters;
using Xunit.Abstractions;

namespace PactNet.Output.Xunit
{
/// <summary>
/// Output to an xUnit test output helper
/// </summary>
public class XunitOutput : IOutput
{
private readonly ITestOutputHelper output;

/// <summary>
/// Initialises a new instance of the <see cref="XunitOutput"/> class.
/// </summary>
/// <param name="output">xUnit test output helper</param>
public XunitOutput(ITestOutputHelper output)
{
this.output = output;
}

/// <summary>
/// Write a line to the output
/// </summary>
/// <param name="line">Line to write</param>
public void WriteLine(string line) => this.output.WriteLine(line);
}
}
3 changes: 2 additions & 1 deletion tests/PactNet.Tests/PactExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using PactNet.Matchers;
using PactNet.Output.Xunit;
using Xunit;
using Xunit.Abstractions;
#pragma warning disable CS0618
Expand Down Expand Up @@ -61,7 +62,7 @@ public PactExtensionsTests(ITestOutputHelper output)
DefaultJsonSettings = jsonSettings,
Outputters = new[]
{
new XUnitOutput(output)
new XunitOutput(output)
}
};

Expand Down
1 change: 1 addition & 0 deletions tests/PactNet.Tests/PactNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\src\PactNet\PactNet.csproj" />
</ItemGroup>

Expand Down
5 changes: 3 additions & 2 deletions tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using PactNet.Exceptions;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -24,7 +25,7 @@ public void HappyPathIntegrationTest()
using var provider = new InteropVerifierProvider(new PactVerifierConfig
{
LogLevel = PactLogLevel.Trace,
Outputters = new[] { new XUnitOutput(this.output) }
Outputters = new[] { new XunitOutput(this.output) }
});

provider.Initialise();
Expand Down Expand Up @@ -62,7 +63,7 @@ public void SetPublishOptions_NoBuildUri_IsValid()
using var provider = new InteropVerifierProvider(new PactVerifierConfig
{
LogLevel = PactLogLevel.Trace,
Outputters = new[] { new XUnitOutput(this.output) }
Outputters = new[] { new XunitOutput(this.output) }
});

provider.Initialise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Moq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using PactNet.Verifier.Messaging;
using Xunit;
Expand Down Expand Up @@ -37,7 +38,7 @@ public MessagingProviderTests(ITestOutputHelper output)
{
Outputters = new[]
{
new XUnitOutput(output)
new XunitOutput(output)
},
LogLevel = PactLogLevel.Debug
}, this.mockScenarios.Object);
Expand Down
Loading