SimpleFluentTester 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleFluentTester --version 0.1.0                
NuGet\Install-Package SimpleFluentTester -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleFluentTester" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleFluentTester --version 0.1.0                
#r "nuget: SimpleFluentTester, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleFluentTester as a Cake Addin
#addin nuget:?package=SimpleFluentTester&version=0.1.0

// Install SimpleFluentTester as a Cake Tool
#tool nuget:?package=SimpleFluentTester&version=0.1.0                

<div align="center">

Simple Fluent Tester <br> 😼

Simple and user-friendly C# testing tool.

Latest release Coveralls NuGet Version

</div>

What is it for?

Let's say you are solving algorithmic problems on a platform like LeetCode or conducting intermediate testing for a complex algorithm.

Would you start writing your own wrappers? This will take some time that could be spent more productively.

Would you use a testing framework? That's a good option, but it requires writing a lot of unnecessary infrastructure code.

Based on my personal experience, I have created a library that allows you to set up the entire testing environment in just a minute!

Instruction

Use your preferred IDE or CLI to install the NuGet package SimpleFluentTester. You can also find the NuGet package at this link.

I assume that you have a very complex function to cover with test cases, but let's say we have a very simple one of some sort:

 int Adder(int number1, int number2)
 {
     return number1 + number2;
 }

Let's start writing test cases for it!

TestSuite.Sequential
     // Here we specify the method we want to test.
    .UseOperation(Adder) 
     // Then we add 2 valid tests and one invalid test.
    .Expect(2).WithInput(1, 1) 
    .Expect(-2).WithInput(-1, -1)
    .Expect(-3).WithInput(-1, -1)
    .Run() 
    .Report();

And the output of this code will indicate that one out of the three test cases has not passed:

05:10:31.455 fail: SimpleFluentTester.Reporter.DefaultTestRunReporter[0]
      Executing tests for target method [Int32 Adder(Int32, Int32)]
      Total tests: 3
      Tests to execute: 3
      
      Test case [3] not passed
        Inputs: '-1', '-1'
        Expected: '-3'
        Output: '-2'
        Elapsed: 0,00050ms
      
      1/3 tests haven't passed!
      Failed test cases: 3
      Elapsed total: 0,16400ms; Avg: 0,05467ms; Max: 0,11000ms [Number 2]

Furthermore, for debugging purposes, for the next run it would be most convenient to select only the unsuccessful test cases:

TestSuite.Sequential
    .UseOperation(Adder) 
    .Expect(2).WithInput(1, 1) 
    .Expect(-2).WithInput(-1, -1)
    .Expect(-3).WithInput(-1, -1)
     // You should not comment on your test cases; just specify the iteration you want to test, every other iteration will be ignored.
    .Run(3) 
    .Report();

Also, you can write your custom reporter that will generate a report in the format you need:

TestSuite.Sequential
    .UseOperation<int>(CustomMethods.Adder) 
    .WithCustomReporterFactory<CustomReporterFactory>() 
    .Expect(2).WithInput(1, 1) 
    .Run()
    .Report();

If your project contains multiple test suites simultaneously, and you wish to debug only one of them, you don't need to comment out the code; simply follow these steps:

TestSuite.Sequential.Ignore // <- add Ignore here and this test run will be fully ignored.
    .UseOperation<int>(CustomMethods.Adder) 
    .Expect(2).WithInput(1, 1) 
    .Run()
    .Report();

If you use non-standard object types in your function, you can define how the TestSuite should compare them yourself.

TestSuite.Sequential
    // Return type of your testable method could be specified with a provided comparer.
    .WithExpectedReturnType<CustomValue>((x, y) => x.Value == y.Value)
    .UseOperation((CustomValue a, CustomValue b) => a.Value + b.Value)
    .Expect(CustomValue.FromInt(2)).WithInput(CustomValue.FromInt(1), CustomValue.FromInt(1))
    .Run()
    .Report();

If you have any questions, you can find all these examples in this project or ask me directly via email!

License

Released under MIT by @EvgenyHalzov.

  • You can freely modify and reuse.
  • The original license must be included with copies of this software.
  • Please link back to this repo if you use a significant portion the source code.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.2 103 6/6/2024
0.3.1 98 4/19/2024
0.3.0 99 4/19/2024
0.2.2 103 4/19/2024
0.2.1 102 4/19/2024
0.2.0 109 3/25/2024
0.1.7 105 3/25/2024
0.1.6 101 3/25/2024
0.1.5 106 3/25/2024
0.1.4 119 3/7/2024
0.1.3 125 3/4/2024
0.1.2 115 3/4/2024
0.1.1 129 3/3/2024
0.1.0 122 3/3/2024
0.0.9 119 3/1/2024
0.0.8 111 2/29/2024
0.0.7 130 2/14/2024
0.0.6 120 2/12/2024
0.0.5 118 2/11/2024
0.0.4 118 2/8/2024
0.0.3 120 2/7/2024
0.0.2 116 2/7/2024
0.0.1 115 2/7/2024