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

Provide optional recursive argument to test_dir() #1605

Open
s-fleck opened this issue Apr 16, 2022 · 3 comments · May be fixed by #1850
Open

Provide optional recursive argument to test_dir() #1605

s-fleck opened this issue Apr 16, 2022 · 3 comments · May be fixed by #1850
Labels
feature a feature request or enhancement tests 📘

Comments

@s-fleck
Copy link

s-fleck commented Apr 16, 2022

Would it be possible to add a recursive argument to test_dir() so that it (optionally) also looks for test files in sub-directories?

Motivation:
I have a workflow where I put long running tests - or tests that needs stuff like database access - in subfolders of the /test directory. This works really well as they are not automatically executed by devtools::test(), but I can still manually trigger them. I even made a package to support this worklfow (testthis).

Now if I want to run all tests in a directory and it's subdirectories at once, I have to resort to some really ugly code where i just use with_mock to override the test file discovery of testthat:

  testthat::with_mock(
    devtools::test(...),
    `testthat::find_test_scripts` = find_test_scripts_mock
  )

I'd really love to be able to remove this abomination from my package, especially since with_mock() is deprecated.

@hadley
Copy link
Member

hadley commented Sep 19, 2022

I'd be happy to review a PR that implemented this.

@hadley hadley added feature a feature request or enhancement tests 📘 labels Sep 19, 2022
radbasa added a commit to Appsilon/testthat that referenced this issue Aug 29, 2023
Give test_dir() a recursive option (r-lib#1605)

The recursive argument allows test files in nested directories.
@radbasa radbasa linked a pull request Aug 29, 2023 that will close this issue
@radbasa
Copy link

radbasa commented Oct 9, 2023

Hello @hadley , I submitted a PR #1850 that gives test_dir() the optional ability to recurse through nested test directories. Would you mind taking a look?

@hadley
Copy link
Member

hadley commented Oct 9, 2023

@radbasa thanks! I'll take a look when I'm next working on testthat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement tests 📘
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants