Session Ready
Exercise

Grouping tests

So far, you've been using expect_*() functions to create individual tests. To run tests in packages you need to group these individual tests together. You do this using a function test_that(). You can use this to group together expectations that test specific functionality.

You can use context() to collect these groups together. You usually have one context per file. An advantage of doing this is that it makes it easier to work out where failing tests are located.

Instructions
100 XP
  • Use context() to set the context to "Test data_summary()".
  • Use test_that() to group the tests below together, giving them the description "data_summary() handles errors correctly".