Run your Peaky tests to validate new deployments using this simple library. Peaky.XUnit makes it easy for xunit to invoke tests from a Peaky endpoint, immediately integrating Peaky test results into your existing test execution infrastructure. We built Peaky.Xunit to simplify service validation inside our Visual Studio Online Release Management pipeline, and the same library can be used anywhere else you want to validate your Peaky tests.
- Validate Peaky tests in XUnit
- Get Peaky results anywhere XUnit runs, including:
- Visual Studio, or your favorite IDE
- Build/Release scripts via
dotnet test
- bash, zsh, powershell, cmd, etc. via
dotnet test
- Integration into results management systems like VSO's Test Run Explorer and Jenkins' Xunit Plugin when executed as
dotnet test --log:trx
These samples are written targetting the sample Peaky endpoint at http://peaky.azurewebsites.net/tests. Just plug in your own Peaky URI to get started!
using System;
using Xunit;
using Peaky.XUnit;
using FluentAssertions;
using Peaky.Client;
namespace Peaky.Sample.Tests
{
public class PeakySampleTests : PeakyXunitTestBase, IDisposable
{
private readonly PeakyClient _peakyClient = new PeakyClient(new Uri("https://peaky.azurewebsites.net/tests"));
public override PeakyClient PeakyClient => _peakyClient;
[Theory]
[ClassData(typeof(PeakySampleTests))]
public async void The_peaky_test_passes(Uri url)
{
var result = await PeakyClient.GetResultFor(url);
result.Passed.Should().BeTrue();
}
public void Dispose()
{
_peakyClient.Dispose();
}
}
}
Note that the only change is the URL passed to PeakyClient. Cool!
using System;
using Xunit;
using Peaky.XUnit;
using FluentAssertions;
using Peaky.Client;
namespace Peaky.Sample.Tests
{
public class PeakySampleTests : PeakyXunitTestBase, IDisposable
{
private readonly PeakyClient _peakyClient = new PeakyClient(new Uri("https://peaky.azurewebsites.net/tests/prod"));
public override PeakyClient PeakyClient => _peakyClient;
[Theory]
[ClassData(typeof(PeakySampleTests))]
public async void The_peaky_test_passes(Uri url)
{
var result = await PeakyClient.GetResultFor(url);
result.Passed.Should().BeTrue();
}
public void Dispose()
{
_peakyClient.Dispose();
}
}
}
Big thanks to @jonsequitur and @piotroko for their contributions to this project!