testex
provides two new roxygen2
tags, @test
and @testthat
.
tags
testex tags are all sub-tags meant to be used within an
@examples
block. They should be considered as tags within the
@examples
block and used to construct blocks of testing code within
example code.
@test
:In-line expectations to test the output of the previous command within an example. If
.
is used within the test expression, it will be used to refer to the output of the previous example command. Otherwise, the result of the expression is expected to be identical to the previous output.
@testthat
:Similar to
@test
,@testthat
can be used to make in-line assertions usingtestthat
expectations.testthat
expectations follow a convention where the first argument is an object to compare against an expected value or characteristic. Since the value will always be the result of the previous example, this part of the code is implicitly constructed for you.If you want to use the example result elsewhere in your expectation, you can refer to it with a
.
. When used in this way, testex will not do any further implicit modification of your expectation.