Code Monkey home page Code Monkey logo

peaky.xunit's Introduction

Build status NuGet Badge

peaky.xunit

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.

Benefits

  • 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

Samples

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!

Run all Peaky Tests for a service

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();
        }
    }
}

Run all Peaky Tests for a specific environment

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();
        }
    }
}

Thanks!

Big thanks to @jonsequitur and @piotroko for their contributions to this project!

peaky.xunit's People

Contributors

jonsequitur avatar colombod avatar piotroko avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.