簡體   English   中英

在 testthat 中捕獲錯誤但不要停止循環 - 測試

[英]Catch the error in testthat but dont stop the loop - testing

我最近寫了一個 package,我想測試幾個函數,這些函數在輸入正確時傳遞 data.frame,如果不正確,它會將輸入作為文件傳遞到錯誤文件夾中並記錄到 log.log 文件中。

現在的問題是:我如何報告這個移動並測試函數是否將文件移動到 test_that 的錯誤文件夾中?

謝謝!

用不正確的輸入調用您的 function,然后檢查錯誤文件是否按您的要求創建,怎么樣?

test_that("Error file is created", {
  yourfunction(x)
  expect_true(file.exists("errorfile.error")
})

yourfunction()之前,您還必須創建不正確的輸入 x。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM