1. Learn
  2. /
  3. Courses
  4. /
  5. Creating R Packages

Exercise

Testing errors

You can use expect_error() to test if running a function returns an error. If the function returns an error, the test will pass, otherwise, it will fail. You can optionally define the error message that should be returned to ensure that you are testing for the correct error.

Instructions

100 XP
  • Call data_summary() on my_vector.
  • Pick an appropriate expect_*() function such that when you call data_summary() on my_vector again, the test passes.