TestSurface 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package TestSurface --version 1.0.6                
NuGet\Install-Package TestSurface -Version 1.0.6                
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="TestSurface" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TestSurface --version 1.0.6                
#r "nuget: TestSurface, 1.0.6"                
#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 TestSurface as a Cake Addin
#addin nuget:?package=TestSurface&version=1.0.6

// Install TestSurface as a Cake Tool
#tool nuget:?package=TestSurface&version=1.0.6                

Test Surface

v1.0

Description

The lib defines a testing contract, provides a command line arguments parser, a simple printing utility and a test runner. In order to use the runner one has to implement the ITestSurface interface:

public interface ITestSurface
{
	string Info { get; }
	string FailureMessage { get; }
	bool? Passed { get; }
	bool IsComplete { get; }
	bool IndependentLaunchOnly { get; }
	Task Run(ArgMap args);
}

The runner can be launched in two modes:

  • with a specific test class and arguments, by passing a -TheTestClassName as a command line parameter
  • with -all to discover all the compatible classes and invoke their Run method. Tests having IndependentLaunchOnly = true will be ignored as they cannot be fed with specific data because that could brake the rest of the tests.

The ArgMap type is an IDictionary<string, List<string>> instance, produced by the ArgsParser. Inside the Run method each test is provided with a copy of the original dictionary, so that common test paths could be reused by adding arguments.

The IDictionary<string, List<string>> holds the switches as keys with the dash (e.g. -all) and a list of string arguments provided in the console after the switch.

Additional arguments:

  • including -info will take the Info property and trace it instead of executing the Run method.
  • with -notrace all Print.AsInfo(), Print.Trace() invocations will be ignored
  • use -brake to stop the test launcher on the first failure

Launching with -all -info will trace all test descriptions.

Use Print to trace info during the test instead of Console directly for it can be suppressed with -notrace and also the Print.Trace() method has a lock for correct coloring in multi-threaded code.

Usage

Add a reference to the TestRunner.dll and implement the ITestSurface interface:

public class TestCase : ITestSurface
{
	public string Info => "Test description...";

	public string FailureMessage { get; private set; }
	public bool? Passed { get; private set; }
	public bool IndependentLaunchOnly => false;
	public bool IsComplete { get; private set; }

	public async Task Run(IDictionary<string, List<string>> args)
	{
		if (args.ContainsKey("-all"))
			// add default switches 
			args.Add("-param", new List<string>() { "10", "1000" });

		// The common path, i.e. either -all or -TestCase
		var w = args["-param"];

		// ...

		if (!Passed.HasValue) Passed = true;
		IsComplete = true;
	}
}

Launch a new Runner instance:

using System;
using TestSurface;

namespace Tests
{
    class Program
    {
        static int Main(string[] args)
        {
            var r = new Runner();
           
            // The args should contain -all or -ClassName
            r.Run(args);
            
            // Check the ResultMap, Exceptions or Passed/Failed/Skipped counters
            return (r.Exceptions.Count < 1 && r.Passed > 0) ? 0 : -r.Failed;
        }
    }
}
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.
  • .NETStandard 2.0

    • No dependencies.

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
1.3.0 573 7/13/2020
1.2.0 600 6/28/2019
1.1.4 513 6/17/2019
1.1.3 557 3/21/2019
1.1.2 539 3/21/2019
1.1.1 548 3/5/2019
1.1.0 543 2/25/2019
1.0.6 560 2/21/2019
1.0.5 619 2/20/2019
1.0.4 613 2/19/2019
1.0.3 632 2/14/2019
1.0.2 622 1/25/2019
1.0.1 600 1/25/2019
1.0.0 686 1/1/2019

Assert.SameValues visits tracker