🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

TestConsole

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

TestConsole

Unit tests will often need to assert that a sizeable amount of data matches an expectation, and this is difficult with only the traditional style of assertion. You essentially have the choice of writing a long list of simple assertions, or concatenating the output into a string and using a single assert against that. However, when these assertions fail it can be very hard to determine in what ways the output differs from the expectation. One solution to this problem is a different workflow from traditional unit testing - instead of making a prediction in the code, and then checking the output against the prediction, what if you formatted the output and displayed it side by side with the last "approved" version. This is what TestConsole.Core provides. On a build server, when the test result does not match the default behaviour is just to fail the test, whereas on a development PC you can configure the library to use an installed file compare utility to display the differences. If the differences are expected, you can copy the new result over to the approved version and the test will pass. TestConsole.Core inherits all of the formatting capabilities from the original TestConsole project, and adds test approval features. Users of ApprovalTests will recognise the workflow and the functionality, but at the time of publishing, ApprovalTests is full framework only, whereas TestConsole.Core is intended to allow testing in both full framework and .NET core test suites. I did not set out to build an alternative to ApprovalTests, but I need to be able to test netcoreapp code, and the conversion of TestConsole was not difficult. However, ApprovalTests did not support netstandard or netcoreapp test suites and I couldn't wait any longer, so I built the subset of ApprovalTests features that I needed into TestConsole.Core from scratch. As a result, the syntax is a little different to ApprovalTests, particularly where it relates to selecting a file compare tool, and also relating to what can be directly approved. The intention of the test approval features is to allow data formatted using the TestConsole Output object to be approved, and I've also extended it to handle any plain text.

Source
nugetNuGet
Version
2.6.0
Version published
Maintainers
1
Created
The README file is missing

Keywords

Unit

FAQs

Package last updated on 03 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts