spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

It would be usefull to allow using the config or a constructor to pass a test console which could be configured externally

Open scarbon opened this issue 11 months ago • 5 comments
trafficstars

It would be usefull to allow the constructor to pass a test console which could be configured externally, I would like to do integration test with interactive test inputs into console but cant do it externally without having to implement my own CommandAppTester since class is sealed. Perhaps just like with a test register we could pass this onto the constructor or maybe use the config console method could be an alternative.

public CommandAppTester(ITypeRegistrar? registrar = null, TestConsole? console = null)
    {
        Registrar = registrar;
        _console = console ?? new TestConsole().Width(int.MaxValue);
    }

Here we coud use the _console https://github.com/spectreconsole/spectre.console/blob/58bf89a56a7f747665acff45484abf9182fd3977/src/Spectre.Console.Testing/Cli/CommandAppTester.cs#L107 https://github.com/spectreconsole/spectre.console/blob/58bf89a56a7f747665acff45484abf9182fd3977/src/Spectre.Console.Testing/Cli/CommandAppTester.cs#L153

Woud be happy to raise a PR (if I'm allowed to)

scarbon avatar Dec 22 '24 00:12 scarbon

@scarbon I like this idea, it fits within the general paradigm of our development, it keeps the class sealed, and I see the usefulness of it. Unless another maintainer tells me otherwise in the next few days, I would welcome this as a PR. However, please do note that suitable test coverage is required. Tag me when opened and I can review the PR.

FrankRay78 avatar Jan 14 '25 23:01 FrankRay78

Related to https://github.com/spectreconsole/spectre.console/issues/1737

FrankRay78 avatar Jan 18 '25 15:01 FrankRay78

Let's get this PR motoring @scarbon.

FrankRay78 avatar Jan 19 '25 20:01 FrankRay78

Related to #1737 Yep exactly what I was thinking with changes I was looking for when Iwas doing advent of code

Dang I was totally going to make this PR I was waiting for reply to my issue. #1713

byte2pixel avatar Jan 27 '25 13:01 byte2pixel

Done. Please review the PR and let me know your thoughts! Thanks https://github.com/spectreconsole/spectre.console/pull/1803

magiino avatar Apr 10 '25 22:04 magiino

Should this issue still be open, now that #1803 has been merged?

Mads-MMJ avatar Jul 23 '25 09:07 Mads-MMJ

Yes. Thanks for telling

patriksvensson avatar Jul 23 '25 20:07 patriksvensson