Mechanism for testing box-package based project structures
- Dominant language
- R
- Stars
- 979
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Since the box package marks a partial departure from traditional R code structures, I would find it useful to also support testing these non-traditional R code structures.
Specifically, `testthat::test_dir()` only tests `test-*.R` files in `/` but not in `//`.
This make sense in a R package structure which does not allow subfolders in `R/`, but making use of `box` I could see structures like `R/database`, `R/utils`, `R/preprocesssing` and so on.
The particular use case here would be to have an easy setup for continuous integration with Github Actions, such as
```
- name: Run tests
run: |
Rscript tests/run_tests.R
```
I haven't found a clean solution with `testthat` that would allow something like this in a `box` setup, like running multiple tests, collecting the status in a single reporter and putting out a single exit code without drilling into the internal code of `testthat`.
I know that this question probably belongs into the `testthat`-repo, but there wasn't much support being signaled for similar questions, and I wondered if you encountered this task already.
I still think that, despite R being very friendly for R-*Users*, the gap to use learn software engineering practices like modularity, unit tests and linting is pretty large, and while there are many similarities for using `box` and python imports or `pipenv` and `renv`, the R package structure does not have a direct analogy I can think of anywhere else, and for a lot of users it's not clear how to break up functionality into packages, then how to manage all these packages, and there are very few guides out there for realistic applications.
So most R users just don't seem to bother, don't write packages and don't write tests, because it seems too daunting. I think combining the `box` package with a CI setup for Github Actions which is now easier than ever might help to mitigate the gap between *using* R and moving towards more solid code.
Contributor guide
Research direction
Start with the proposed tests/run_tests.R entry point and the behavior of testthat::test_dir(), then review how box projects organize nested R and test directories. Done means a documented mechanism can discover nested tests, combine their results into one reporter, and return a single CI exit code for the GitHub Actions command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, r
- Domain
- ci-cd, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100