The testthat package in R offers two ways to structure your tests:
describe()is a BDD implementation, where you give a "description of the feature". Within this, you have several sets of specifications calleditblocks. These contain the actual assertions /expectcalls, and have their own description, which is concatenated to the feature description in the printout if a test failstest_that()takes a "test name", followed by code for the test.
The idea seems to be that describe() is used for big features/objects, whereas test_that() is used for "smaller, self-contained" sets of functionality, but I'm not sure that I understand the distinction, since I thought denoting "features" is what context() is used for, and features are supposed to be self-contained anyway.
In the describe() documentation, we are told the following:
Use describe to verify that you implement the right things and use test_that() to ensure you do the things right.
This is a very brief distinction that seems to be lacking context. Hadley Wickham's R packages book doesn't mention describe() at all, so I can't look there for clarification either.
My guess is that, roughly, describe() is for acceptance tests, and test_that() is for unit tests. What am I missing by using this assumption, and what is the intended use difference?
Aucun commentaire:
Enregistrer un commentaire