rstudio / shinytest2

https://rstudio.github.io/shinytest2/
Other
103 stars 16 forks source link

No code coverage for `{shiny}` applications #268

Closed ei-ds closed 1 year ago

ei-ds commented 1 year ago

I'm coming from {shinytest} and have issues with code coverage reported by {covr} when using {shiny} modules.

I prepared a simple test package with an app defined in inst as described in the documentation located here: https://github.com/ei-ds/testshinytest2. I modified the code to use {shiny} modules. The app can be started with runApp(system.file("hello", package = "testshinytest2")) after installing the {testshinytest2} package.

Tests succeed without errors.

However, when running covr::package_coverage() the file R/hello-world is reported to be not covered by the test.

With {shinytest} I followed the steps described in https://github.com/r-lib/covr/issues/277#issuecomment-555502769 and was able to get coverage reported correctly as well for {shiny} modules.

Are there any similar steps to do to get coverage reported correctly with {shinytest2} as well or is this feature not implemented, yet?

schloerke commented 1 year ago

@ei-ds This is currently a limitation for {shinytest2}. Since shiny server is run in a background R process (and not the current R process), it does not inherit all of the {covr} initialization for reporting.

The unfortunate part is we can not reverse the execution processes and have the test code in the background and the app code in the foreground. Because of this, I do not see a way forward allowing {covr} to report test coverage of a background R process to the foreground R process.

(Sorry to be the bearer of bad news!)

schloerke commented 1 year ago

Closing for now as there are no plans to fix this situation within {shinytest2}