是否可以在testthat中确定测试顺序? [英] Is it possible to determine test order in testthat?

查看:56
本文介绍了是否可以在testthat中确定测试顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用testthat来检查包装中的代码.我的一些测试是针对基本功能的,例如构造函数和吸气剂.其他的则是在基本功能之上构建的复杂功能.如果基本测试失败,那么预期复杂测试将失败,因此没有进一步的点测试.

I am using testthat to check the code in my package. Some of my tests are for basic functionality, such as constructors and getters. Others are for complex functionality that builds on top of the basic functionality. If the basic tests fail, then it is expected that the complex tests will fail, so there is no point testing further.

是否可以:

  1. 确保始终先进行基本测试
  2. 使测试失败以终止测试过程

推荐答案

要回答您的问题,除了对您的test-*.R文件使用适当的字母数字命名之外,我认为无法确定.

To answer your question, I don't think it can be determined other than by having appropriate alphanumeric naming of your test-*.R files.

testthat源,这是test_package通过test_dir调用以获取测试的函数:

From testthat source, this is the function which test_package calls, via test_dir, to get the tests:

find_test_scripts <- function(path, filter = NULL, invert = FALSE, ...) {
  files <- dir(path, "^test.*\\.[rR]$", full.names = TRUE)

反正让复杂的任务首先失败有什么问题?

What is wrong with just letting the complex task fail first, anyway?

这篇关于是否可以在testthat中确定测试顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆