-
Notifications
You must be signed in to change notification settings - Fork 341
Closed
Description
We currently lack a good way to create compound expectations. The simplest approach has two problems:
expect_numeric_length_10 <- function(x) {
expect_type(x, "numeric")
expect_length(x, 10)
}- It can generate two successes or two failures
- The
trace_envis incorrect so you get an unnecessary backtrace
We don't suffer too much from 1. in testthat itself but we do have a lot of 2. Mostly in helpers (where we do set trace_env correctly:
expect_true()β callsexpect_waldo_constant()expect_false()β callsexpect_waldo_constant()expect_null()β callsexpect_waldo_constant()expect_equal()β callsexpect_waldo_equal()expect_identical()β callsexpect_waldo_equal()expect_error()β callsexpect_condition_matching()expect_warning()β callsexpect_condition_matching()expect_message()β callsexpect_condition_matching()expect_condition()β callsexpect_condition_matching()expect_no_error()β callsexpect_no_()expect_no_warning()β callsexpect_no_()expect_no_message()β callsexpect_no_()expect_no_condition()β callsexpect_no_()
But there are a few places where we call exported expect_ functions and hence can't control the trace_env
expect_mapequal()β callsexpect_equal()expect_output()β callsexpect_match()expect_snapshot_failure()β callsexpect_snapshot_error()expect_snapshot_skip()β callsexpect_snapshot_error()expect_skip()β callsexpect_condition()expect_no_skip()β callsexpect_no_condition()
It would be nice to have general solution to using an existing expectation inside a new expectation.
Metadata
Metadata
Assignees
Labels
No labels