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

Helper code and files for your testthat tests - R-hub blog #138

Open
utterances-bot opened this issue Dec 2, 2020 · 9 comments
Open

Helper code and files for your testthat tests - R-hub blog #138

utterances-bot opened this issue Dec 2, 2020 · 9 comments

Comments

@utterances-bot
Copy link

Helper code and files for your testthat tests - R-hub blog

https://blog.r-hub.io/2020/11/18/testthat-utility-belt/

Copy link

dmenne commented Dec 2, 2020

Thanks for nicely filling up the missing part in our earlier discussion.

One point I am missing: I have tests that have to be run manually, because they are integration tests for an API hitting a live server. I add these as sibblings of testthat:

test
  testthat.R
  /testlive
     helper-globals-live.R
     run-testlive.R
  /testthat
  /testdata 

Using httptest, the testthat directory either contacts the apiary server to create the response files, (https://odkcentral.docs.apiary.io/), or uses the response files as a mock in travis/CRAN.

I put the testdata shared between unit-test and integration tests in another sibbling directory.

Any comments or better ideas?

@maelle
Copy link
Member

maelle commented Dec 2, 2020

Thanks for reading!

I think it sounds ok? In the Whole Games section of https://books.ropensci.org/http-testing/ I suggest some workflows for tests with real requests but yours seems to work 🙂

@maelle
Copy link
Member

maelle commented Dec 2, 2020

Aside question, what does your package do compared to https://docs.ropensci.org/ruODK/?

@dmenne
Copy link

dmenne commented Dec 2, 2020

It is a complement to ruODK, which I also use. ruODK is focused on getting the data for offline-reading. odkapi is strict REST API, using XSLT for conversion of all output to data frames. And it is lean, using no tidyverse. I am not ideologically opposed to tidyverse and use it every day writing fire-and-forget reports, but I have three package (breathtestXXX, gastempt) that use it, and the amount of work I put into keeping up with tidyverse changes is just to massive. 75% tidyverse problems, 20% rstan/rcpp.

I use it to build a highly simplified form upload/test RGui for clinical use. The official Web Interface one is highly confusing for end users and will never pass usage tests in a clinical context. Even if I use it the web interface daily, I never find the place where to get the test or the user QR code. Or been thrown back to rename the form when I upload it . Or the confusing warning that cannot be switched off that the repeat behaviour has changed.

@dmenne
Copy link

dmenne commented Dec 2, 2020

Aside question, what does your package do compared to https://docs.ropensci.org/ruODK/?

Which I clearly have read.... Since I had used httptest before, I sticked with it, even if you prefer vcr and friends.

@maelle
Copy link
Member

maelle commented Dec 2, 2020

The http testing book is getting updated, I added a chapter about httptest yesterday 😉

@dmenne
Copy link

dmenne commented Dec 2, 2020

Bummer -- when do you have time to do your real work .:)

Copy link
Member

Bisaloo commented Jul 21, 2023

I stumbled upon this post again while reading https://ropensci.org/blog/2023/07/21/news-july-2023/#package-development-corner.

Would you say that the statement

tests/testthat/helper*.R are no longer recommended in testthat but they are still supported. 😌

is still true?

These helper files are mentioned, without any mention of them being deprecated, in a somewhat new testthat vignette (r-lib/testthat#1769): https://testthat.r-lib.org/articles/special-files.html#helper-files

@maelle
Copy link
Member

maelle commented Jul 21, 2023

I think they'll be supported forever but I'm not sure they're recommended? I use them a lot in any case. 😅

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

No branches or pull requests

4 participants