Skip to content

A collection of libraries to aid in testing with XUnit

License

Notifications You must be signed in to change notification settings

frankhaugen/Frank.Testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frank.Testing

A set of nugets to allow for easier testing of dotnet code using xUnit


GitHub License NuGet NuGet

GitHub contributors GitHub Release Date - Published_At GitHub last commit GitHub commit activity GitHub pull requests GitHub issues GitHub closed issues


Installation

NuGet

Install-Package Frank.Testing

.NET CLI

dotnet add package Frank.Testing

Usage

TestOutputHelperExtensions

using Xunit;
using Xunit.Abstractions;

public class MyTestClass
{
    private readonly ITestOutputHelper _outputHelper;

    public MyTestClass(ITestOutputHelper outputHelper)
    {
        _outputHelper = outputHelper;
    }

    [Fact]
    public void MyTestMethod()
    {
        _outputHelper.WriteLine(new { MyProperty = "MyValue" }); // Writes to test output as JSON: {"MyProperty":"MyValue"}
        _outputHelper.WriteJson(new { MyProperty = "MyValue" }); // Writes to test output as JSON: {"MyProperty":"MyValue"}
    }
    
    [Fact]
    public void MyTestMethod2()
    {
        _outputHelper.WriteCSharp(new { MyProperty = "MyValue" }); // Writes to test output as C#: var anonymousType = new { MyProperty = "MyValue" };
    }
    
    [Fact]
    public void MyTestMethod3()
    {
        _outputHelper.WriteXml(new MyClass() { Name = "MyName" }); // Writes to test output as XML: <MyClass><Name>MyName</Name></MyClass>
    }
}