Unit test Spectre.Console.Cli app console output always blank #1232
-
I have a CommandApp written in NET 7.0. I have tried to use the CommandAppTester wrapper, but the CommandAppTester.Output is always blank string
The If I use the Any guidance would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I might have answered my own question by using a combination of Dependency Injection and CommandAppTester. So in Program.cs Main method
Injected the
Also, if testing the Command directly instead of doing App.Run... people have used AnsiConsole.Record() and AnsiConsole.ExportText() approaches, but found that with the DI approach above I can just inject my own console and view it's output without concerns of threading issues.
|
Beta Was this translation helpful? Give feedback.
I might have answered my own question by using a combination of Dependency Injection and CommandAppTester.
So in Program.cs Main method
Injected the
IAnsiConsole
into theGenerateCardNumberCommand