CheckTestOutput 0.1.0
See the version list below for details.
dotnet add package CheckTestOutput --version 0.1.0
NuGet\Install-Package CheckTestOutput -Version 0.1.0
<PackageReference Include="CheckTestOutput" Version="0.1.0" />
paket add CheckTestOutput --version 0.1.0
#r "nuget: CheckTestOutput, 0.1.0"
// Install CheckTestOutput as a Cake Addin #addin nuget:?package=CheckTestOutput&version=0.1.0 // Install CheckTestOutput as a Cake Tool #tool nuget:?package=CheckTestOutput&version=0.1.0
CheckTestOutput
A very simple library that performs a check that the test output is same as last time. It compares the test output with version from git index, if it does not fit it simply throws an exception. To accept the new version of output, simply stage the changed file.
Although it's a nice idea that tests should verify if the results are correct by some smart logic, it not always possible/practical. In that cases, you may end up with a assert that simply checks if the result is equal to one of the valid outputs which is annoying to maintain. This project just makes it less annoying.
Usage
It requires your project to be in git. You can use any test framework you want, this thing just throws some exceptions, I'll use XUnit here. CheckTestOutput
class just checks if some files match output from your test. The constructor parameter specifies where are the files going to be stored relative to the test file (it uses C#/F# called info feature), in this case it's "testoutputs". The file name is the method name, in this case "SomeTest.TestString".
This is how you check if simple string matches:
public class SomeTest
{
CheckTestOutput check = new CheckTestOutput("testoutputs");
[Fact]
public void TestString()
{
string someData = DoSomeComputation();
check.CheckString(someData);
}
}
You can also check if a collection of lines matches:
[Fact]
public void TestLines()
{
IEnumerable<string> someData = GetSomeResults().Select(a => a.ToString());
check.CheckLines(someData);
}
Or, you can check if object matches when serialized to JSON (using Newtonsoft.Json)
[Fact]
public void TestObject()
{
PersonViewModel someData = GetDefaultPersonDetail();
check.CheckJsonObject(someData);
}
In case you want to use more that one check in one test, you can give them names (so they don't end up overriding themselves):
[Fact]
public void TestWithMultipleChecks()
{
PersonViewModel person = GetDefaultPersonDetail();
check.CheckString(someData.CurriculumVitae, checkName: "cv");
check.CheckString(someData.Genome, checkName: "genome");
}
Or you can combine them into one anonymous JSON object (this is preferable when it's short - you don't end up with so many tiny files):
[Fact]
public void TestWithMultipleChecks()
{
PersonViewModel person = GetDefaultPersonDetail();
check.CheckJsonObject(new { fname = person.Name, lname = person.LastName, person.BirthDate });
}
The text files have .txt
file extension by default, if that annoys you because your strings have some specific format and syntax highlighting does not work in text files...
[Fact]
public void GenerateSomeCsharpCode()
{
string code = GimmeSourceCode();
check.CheckString(code, fileExtension: "cs");
}
Just keep in mind that dotnet is going to treat these .cs
files as part of source code unless you <Compile Remove="testoutputs/**.cs" />
them in the .csproj
file.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- MedallionShell (>= 1.5.1)
- Newtonsoft.Json (>= 12.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on CheckTestOutput:
Repository | Stars |
---|---|
riganti/dotvvm
Open source MVVM framework for Web Apps
|
Version | Downloads | Last updated |
---|---|---|
0.6.3 | 1,519 | 7/30/2023 |
0.6.2 | 143 | 7/30/2023 |
0.6.1 | 149 | 7/25/2023 |
0.6.0 | 556 | 1/28/2023 |
0.5.1 | 2,119 | 6/11/2022 |
0.4.3 | 2,623 | 6/16/2022 |
0.4.2 | 9,475 | 11/7/2021 |
0.4.1 | 299 | 11/7/2021 |
0.4.0 | 3,013 | 7/17/2020 |
0.3.0 | 653 | 12/20/2019 |
0.2.2 | 613 | 3/5/2019 |
0.2.1 | 574 | 3/5/2019 |
0.2.0 | 694 | 3/1/2019 |
0.1.0 | 863 | 1/23/2019 |