Skip to content
R for the Rest of Us: A Statistics-Free Introduction is out now! Check it out →
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Working in the exercises.Rmd file:

  • Both test-count-donations.R and test-tables.R use donations_test_data. Let’s move it to a helper file. First, create the file with fs::file_create(“tests/testthat/helper-donations_data.R”).

  • Open it manually or use edit_file().

  • Move the code to create donations_test_data into helper- donations_data.R.

  • Remove the donations_test_data code from the two test files.

  • Run the tests.

Learn More

The blog post Helper code and files for your testthat tests by Maëlle Salmon can be helpful to learn about types of test files.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.