简体   繁体   English

在R test中处理测试工作流程

[英]Handling Test Workflows in R testthat

I've two files test_utils.r and test_core.r , they contain tests for various utilities and some core functions separated into different 'context'. 我有两个文件test_utils.rtest_core.r ,它们包含针对各种实用程序的测试以及一些分为不同“上下文”的核心功能。 I can control the flow of tests within each file by moving around my test_that() statements. 我可以通过移动test_that()语句来控制每个文件中的测试流程。

But am looking for a way in which I can create different workflows, say ensuring that at run time, tests from Context A_utils runs first followed by tests from Context B_Core followed by context B_Utils. 但是我正在寻找一种方法来创建不同的工作流,例如确保在运行时先运行Context A_utils的测试,然后再运行Context B_Core的测试,再运行上下文B_Utils。

Any ideas on how this can be achieved? 关于如何实现的任何想法?

BrajeshS, BrajeshS,

  1. I have an idea. 我有个主意。 Have you tried the skip() function in version 0.9 or better? 您是否在0.9或更高版本中尝试过skip()函数? See documentation on page 7: 请参阅第7页的 文档

    Description 描述

    This function allows you to skip a test if it's not currently available. 此功能可让您跳过当前不可用的测试。 This will produce an informative message, but will not cause the test suite to fail. 这将产生信息,但不会导致测试套件失败。

    It was introduced to skip tests if an internet connection or API not available. 引入它是为了在Internet连接或API不可用时跳过测试。 You could then dependent on your workflow, jump over tests. 然后,您可以取决于您的工作流程,跳过测试。

  2. To see example code using skip_on_cran, look at wibeasley's answer where he provides test code in Rappster's reply - https://stackoverflow.com/a/26068397/4606130 要使用skip_on_cran看到示例代码,看看wibeasley的回答,他提供了Rappster的答复测试代码- https://stackoverflow.com/a/26068397/4606130

I am still getting to grips with testthat. 我仍然对testthat有所了解。 Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM