Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么时候应该使用descripe()和test_()呢?_R_Testing_Testthat - Fatal编程技术网

什么时候应该使用descripe()和test_()呢?

什么时候应该使用descripe()和test_()呢?,r,testing,testthat,R,Testing,Testthat,R中的testthat包提供了两种构建测试的方法: descripe()是一个BDD实现,您可以在其中给出“功能描述”。在这一部分中,您有几组称为it块的规范。它们包含实际的断言/expect调用,并具有自己的描述,如果测试失败,这些描述将连接到打印输出中的功能描述 test\u that()接受一个“测试名称”,后跟测试代码 这个想法似乎是descripe()用于大型功能/对象,而test\u()用于“较小的、自包含的”功能集,但我不确定我是否理解其区别,因为我认为表示“功能”是conte

R
中的
testthat
包提供了两种构建测试的方法:

  • descripe()
    是一个BDD实现,您可以在其中给出“功能描述”。在这一部分中,您有几组称为
    it
    块的规范。它们包含实际的断言/
    expect
    调用,并具有自己的描述,如果测试失败,这些描述将连接到打印输出中的功能描述
  • test\u that()
    接受一个“测试名称”,后跟测试代码
这个想法似乎是
descripe()
用于大型功能/对象,而
test\u()
用于“较小的、自包含的”功能集,但我不确定我是否理解其区别,因为我认为表示“功能”是
context()
的用途,无论如何,功能都应该是独立的

descripe()
文档中,我们被告知:

使用descripe来验证您实现了正确的事情,并使用test_that()来确保您做了正确的事情

这是一个非常简短的区别,我缺乏背景知识来理解。Hadley Wickham的R软件包书根本没有提到
descripe()
,所以我也不能在那里寻找澄清

我的猜测大概是,
descripe()
用于验收测试,
test\u()
用于单元测试。使用这个假设我遗漏了什么?预期用途的差异是什么