Skip to content
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.

For this section of the course, you’ll need the materials in this GitHub repo. You can download or clone them. After you download or clone the materials from the GitHub repo for this section of the course, open the entire project by clicking 04_avalanchr.Rproj.

Your Turn

Working in the exercises.Rmd file:

  • Use use_test() to create a new file. Call it “resident_connection”

  • Change the test description (the first argument of test_that()) to “connection is returning valid data”

  • In the test_that() function, remove the default expectations. Replace them with this code

  • Re-load your package.

  • Press the “Run tests” button in RStudio (above the script pane) or run test_file(“tests/testthat/test-resident_connection.R”) in the console.

Learn More

To learn about the testthat package, check out its website.

The R Packages book has a good chapter on testing.

Shannon Pileggi has also written a blog post called Getting started with unit testing in R.

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

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