coverlet
coverlet copied to clipboard
coverlet.exe / application coverage: exception "application does not have a console or when console input has been redirected"
Hello,
I tried to collect application coverage (coverlet.exe
) from a simple .net core 3.1 console application which reads from standard input (Console.ReadKey()
). I got an exception. It looks like coverlet.exe does not provide/pass/redirect standard input to the executed program.
The error I got was:
$ coverlet.exe bin/Debug/netcoreapp3.1/console2.exe --target bin/Debug/netcoreapp3.1/console2.exe --include-test-assembly
Hello World!
Press any key to continue...
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
at System.ConsolePal.ReadKey(Boolean intercept)
at System.Console.ReadKey()
at console2.Program.Main(String[] args) in C:\Users\pkruk\source\repos\console2\Program.cs:line 11
Calculating coverage result...
Generating report 'C:\Users\pkruk\source\repos\console2\coverage.json'
+----------+------+--------+--------+
| Module | Line | Branch | Method |
+----------+------+--------+--------+
| console2 | 0% | 100% | 0% |
+----------+------+--------+--------+
+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 0% | 100% | 0% |
+---------+------+--------+--------+
| Average | 0% | 100% | 0% |
+---------+------+--------+--------+
Attaching the console2 project for your convenience: console2.zip
I'm using coverlet.exe 1.7.0.0
Thanks for reporting this
I'm not sure if this is something we want to support. My expectation for a console test runner is that it runs to completion in a non-interactive way. I don't think I'll classify it as a bug
I thought it simply collects coverage from executed application...
I'm not sure if this is something we want to support. My expectation for a console test runner is that it runs to completion in a non-interactive way. I don't think I'll classify it as a bug
Since next version we allow e2e test coverage, so maybe also a console app that accepts input could be a use case, what do you think @tonerdo?
Do you know when that next version will be available?
Since next version we allow e2e test coverage, so maybe also a console app that accepts input could be a use case
I prefer to spend more time optimizing for the common case which is usually non-interactive runs in CI servers. Even when using the integration test feature
Moved to enhancement
@pkruk2 the idea is to release within end of the year.
This issue is stale because it has been open for 3 months with no activity.