Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Proposal: Additional test roxygen headers for more granular metadata #1972

Closed
dgkf-roche opened this issue Jul 12, 2024 · 2 comments
Closed

Comments

@dgkf-roche
Copy link

In my experience within the regulated industry space, many software teams are looking for more granular documentation about tests. Broadly, this could also provide a good avenue for adding other test qualities.

At my place of work we've explored some early POCs for adding roxygen2 headers to testthat::test_that blocks and wanted to float the idea upstream.

#' @meta author dgkf
#' @meta feature cli
test_that("cli printing works as expected") {
  ...
})

This is largely inspired by a pattern for using pytest marks for attaching test metadata:

@pytest.mark.metadata(
    author="dgkf",
    feature="cli"
)
def test_cli_printing():
    ...

Although metadata is certainly the focus of this proposal, adopting roxygen headers for tests could have other benefits, such as allowing for better-documented tests with separation of succinct title and longer-form description for complicated test scenarios and possibly using it as a more consistent location to tag tests as "skip on" or other flags.

For the sake of discussion, a reckless re-imagining of the test api could look something like:

#' cli printing works as expected
#'
#' Test that a sensible cli is displayed regardless of terminal capabilities, 
#' testing fully ansi-capable ttys, dynamic last-line capable tty renderers
#' like RStudio and a simplified ascii-only output.
#'
#' @meta author dgkf
#' @meta feature cli
#'
#' @skip-on CRAN, CI
test({
  ...
})
@hadley
Copy link
Member

hadley commented Oct 22, 2024

I think this is an interesting idea, but I think unfortunately it's out of scope for testthat.

@hadley hadley closed this as completed Oct 22, 2024
@dgkf-roche
Copy link
Author

Thanks for confirming! This was my suspicion, but I wanted to float it here first as to not split the ecosystem unnecessarily.

We've got a little POC that implements a new reporter for this - effectively a JunitReporter that parses the roxygen headers and inserts them into the junit output. I'll see if we can get it open-sourced now knowing that this is something you feel is best served by a supporting package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants