spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.17k stars 472 forks source link

Testing documentation #1410

Open patriksvensson opened 8 months ago

patriksvensson commented 8 months ago

Discussed in https://github.com/spectreconsole/spectre.console/discussions/1409

Originally posted by **csc530** December 22, 2023 I think there should be dedicated documentation for using the `Spectre.Console.Testing` classes on the main website as it's a little hidden that SpectreConsole supports testing with it. And it's not super easy looking through the [source code](https://github.com/spectreconsole/spectre.console/tree/main/test) test to figure out which classes to use and how for whatever purpose you have (as seen in #912). Right now there is a blurb under best practices... > Unit Testing Best Practices For testing of console output, Spectre.Console has [IAnsiConsole](https://spectreconsole.net/api/Spectre.Console/IAnsiConsole) that can be injected into your application. The [Spectre.Console.Test](https://www.nuget.org/packages/Spectre.Console.Testing/) contains a set of utilities for capturing the output for verification, either manually or via a tool such as [Verify](https://github.com/VerifyTests/Verify). I think it could be featured more prominently in its own section with use cases, examples, etc. (I'm also happy to help start/contribute to these docs too).

Please upvote :+1: this issue if you are interested in it.

csc530 commented 8 months ago

I made a PR that adds some pages to show the existence of the testing classes and how to use them. Although I'm not sure how to add API documentation for the test classes to docs. I tried adding the line "../../src/Spectre.Console.Testing/**/{!bin,!obj,!packages,!*.Tests,}/**/*.cs", to the sourceFiles setting list in the docs/Program.cs file, but it didn't seem to work.