简体   繁体   English

测试外部 excel output 与 R testthat package

[英]testing external excel output with R testthat package

I'm trying to test a function of mine with the testthat package. The function is supposed to create an excel file, and I want to test if that excel file exists and contains the things it's supposed to contain.我正在尝试用 package 测试我的 function。function 应该创建一个 excel 文件,我想测试 excel 文件是否存在并包含它应该包含的内容。 I tried running the function to create a simple mockup excel file and then reading in the output again, but that seems to not do anything, I'm guessing because of the localized testing environment.我尝试运行 function 来创建一个简单的模型 excel 文件,然后再次读取 output,但这似乎没有做任何事情,我猜是因为本地化测试环境。 I also feel like writing code outside of the tests is not a good idea since it gave me a warning message about it.我也觉得在测试之外编写代码不是一个好主意,因为它给了我一个关于它的警告信息。 Is there a way to test an external output with testthat that I don't know about?有没有办法用我不知道的 testthat 测试外部 output? I'm new to unit testing and this package so any help would be appreciated.我是单元测试和这个 package 的新手,所以我们将不胜感激。

I actually solved this myself by accident: code run in test_that DOES produce output, just in the test folder.实际上我自己偶然解决了这个问题:在 test_that 中运行的代码确实产生了 output,就在测试文件夹中。 I could read it from there and then test.我可以从那里读取它然后进行测试。

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

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