Learn R Programming

testthat (version 0.1.1)

expect_that: Expect that a condition holds.

Description

Expect that a condition holds.

Usage

expect_that(object, condition)

Arguments

object
object to test
condition,
a function that returns whether or not the condition is met, and if not, an error message to display.

Details

An expectation checks whether a single condition holds true. testthat currently provides the following expectations. See their documentation for more details

Expectations are arranged into tests with test_that and tests are arranged into contexts with context.

Examples

Run this code
expect_that(5 * 2, equals(10))
expect_that(sqrt(2) ^ 2, equals(2))
expect_that(sqrt(2) ^ 2, is_identical_to(2))

Run the code above in your browser using DataLab