JustChecking 1.0.0

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

// Install JustChecking as a Cake Tool
#tool nuget:?package=JustChecking&version=1.0.0

JustChecking

JustChecking is an API namespace that assists with creating automated checks. Checks are observations made of computationally measurable facts where we want to report when a fact is demonstrated to be untrue. Checks are used part of testing a product behavior or attributes.

Usage

The recommended way to use the JustChecking namespace is to wrap everything inside of a Check object. This allows assignment of a meaningful name to a Check, as well as treating all logged events as children of the check. From the Check object you can derive CheckFailsIf and NonProductFailure objects to record check failures and failures not against the product, respectively. Alternatively, you can use the ExpectedSteps object to allow product failure if necessary steps are skipped.

Example code

The following C# code is a demonstration of using a Check and ExpectedSteps object to test an API on an object. `

   [TestMethod]
    public void AddString()
    {
        using (JustChecking.Check check = new JustChecking.Check(MethodBase.GetCurrentMethod().Name, _structuredLogger))
        {
            using(JustChecking.ExpectedSteps expectedSteps = new ExpectedSteps(new string[] { "create SUT", "add string 1", "add string 2", "check sut content" }, _structuredLogger))
            {
                SUT sut = null;
                expectedSteps.Step("create SUT", () => {  sut = new SUT(); });
                expectedSteps.Step("add string 1", () => { sut.AddString("string1"); });
                expectedSteps.Step("add string 2", () => { sut.AddString("string2"); });
                expectedSteps.Step("check sut content", () => { check.CheckFailsIf().AreNotEqual(2, sut.Strings.Length, "string count in sut compared to expected count.");});
            }
        }
    }

`

API

CheckFailsIf

CheckFailsIf is the primary class in the API that exposes a number of comparison methods used to establish whether or not a given fact is untrue. CheckFailsIf is an instance rather than static class, allowing for proper isolation of logging behaviors in the case of parallel script execution. This is similar to other APIs used in automated product checking, except that rather than asserting correct behavior, we state the conditions under which a check is going to fail. This conforms more correctly and consistently with the realities of observation and checking, in that we cannot prove correctness of a product, but we can disprove correctness with evidence.

ExpectedSteps

A class that allows a script to specify that a set of steps are expected. ExpectedSteps implements IDisposable, and will report a check failure if any of the steps specified are not executed. Steps are executed by calling the Step method with the name of the corresponding step and a delegate action to perform the step. Steps can likewise call steps, which are represented in logged output hierarchically.

NonProductFailure

A class that will log failure when created. It is intended for use when the automated script knows for certain that a given failure is not due to any product under test behaviors. The caller may specify categories of reasons indicating if the failure occured prior to, after product interactions, or were simply during actions not related to product interaction.

IStructuredLogger

Takes structured log entries and converts them to formatted output, using ILogWriter objects to record logs to different storage locations.

XmlStructuredLogger

Implements IStructuredLogger and converts log entries to Xml format.

ILogWriter

ILogger is a logging interface passed to checking objects that allow writing of diagnostic information to some location. It is a public interface, permitting integration of JustChecking with various data and reporting sources.

ConsoleLogger

Implements ILogger and writes information to standard output.

FileBasedLogger

Implements ILogger and writes information to a specified file path.

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • 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.1.0 151 5/7/2023
1.0.0 143 5/4/2023

Initial package.