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

Give test_dir() a recursive option #2

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

radbasa
Copy link
Collaborator

@radbasa radbasa commented Feb 6, 2023

Because of this Appsilon/rhino#440, the recursive rhino::test_r() PR Appsilon/rhino#433 may not be sustainable. It works outside of testthat. To provide an experience similar to testthat::test_dir(), I just copied the stdout prompts of ProgressReporter. This cannot accommodate a specific reporter like JunitReporter or any other reporters.

This is a proposed solution inside testthat.

How to test

Build and install on local. Set up an R project with nested test directories.

  1. testthat::test_dir("tests/testthat/") will work as before. Just one single directory, and with the default reporter.
  2. testthat::test_dir("tests/testthat/", recursive = TRUE) to run all of the test scripts in all directories in tests/testthat. testthat::test_dir() will only see scripts with the ^test.*\\.[rR]$ filename.
  3. testthat::test_dir("tests/testthat/", recursive = TRUE, reporter = "Junit") the same as (2) above, but display Junit format.

Unit tests

  1. testthat::test_dir("tests/testthat/") will show test-files has no failures.
  2. testthat::test_file("tests/testthat/test-test-files.R") should pass.
  3. devtools::test() throws an error even on main branch: Error in teardown_env()`.

@radbasa radbasa self-assigned this Feb 6, 2023
@radbasa radbasa merged commit 1b9af10 into recursive-test-dir Aug 29, 2023
radbasa added a commit that referenced this pull request Aug 29, 2023
* give a recursive directories option

* unit test for recursive = TRUE
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

Successfully merging this pull request may close these issues.

2 participants