我使用R包testthat
包括一个测试的一个简单的例子,testthat包“标签”参数
testthat::expect_equal(1,0, label = 'First')
Error: First not equal to 0.
1/1 mismatches
[1] 1 - 0 == 1
标签参数替代“1”由一个字,得到更实用的错误消息。现在我有兴趣替换'0'。这样,我们得到类似
Error: First not equal to Second.
我已经试过这
testthat::expect_equal(1,0, label = c('First', 'Second'))
Error in stop(exp) : bad error message
然而,这并不按照您可能会看到。 我读了封装上的小插图,但是这个参数没有太多的信息。