由于使用 testthat 进行测试,包在 CRAN 上失败
Package fail on CRAN due to test using testthat
我向 CRAN 提交了我的包,但它没有通过 CRAN R CMD 检查。
这是他们得到的错误:
* checking tests ... ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(testthat)
> library(prepdat)
>
> test_check("prepdat")
Error: On CRAN
testthat results ================================================================
OK: 0 SKIPPED: 0 FAILED: 0
Execution halted
这是我的测试文件的样子(这里是 link 到 GitHub https://github.com/ayalaallon/prepdat
skip_on_cran()
library(prepdat)
data("finalized_stroopdata")
data("stroopdata")
context("Finalized table")
test_finalized_stroopdata <- prep(
dataset = stroopdata
, file_name = NULL
, file_path = NULL
, id = "subject"
, within_vars = c("block", "target_type")
, between_vars = c("order")
, dvc = "rt"
, dvd = "ac"
, keep_trials = NULL
, drop_vars = c()
, keep_trials_dvc = "raw_data$rt > 100 & raw_data$rt < 3000 & raw_data$ac == 1"
, keep_trials_dvd = "raw_data$rt > 100 & raw_data$rt < 3000"
, id_properties = c()
, sd_criterion = c(1, 1.5, 2)
, percentiles = c(0.05, 0.25, 0.75, 0.95)
, outlier_removal = 2
, keep_trials_outlier = "raw_data$ac == 1"
, decimal_places = 0
, notification = TRUE
, dm = c()
, save_results = FALSE
, results_name = "results.txt"
, results_path = NULL
, save_summary = FALSE
)
test_that("Finialized table is correct", {
expect_equal(test_finalized_stroopdata, finalized_stroopdata)
})
我该如何解决这个问题?
非常感谢任何帮助,
阿亚拉
您使用 skip_on_cran
不正确。它需要包含在您的 test_that
块中:
test_that("Finialized table is correct", {
skip_on_cran()
expect_equal(test_finalized_stroopdata, finalized_stroopdata)
})
我向 CRAN 提交了我的包,但它没有通过 CRAN R CMD 检查。 这是他们得到的错误:
* checking tests ... ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(testthat)
> library(prepdat)
>
> test_check("prepdat")
Error: On CRAN
testthat results ================================================================
OK: 0 SKIPPED: 0 FAILED: 0
Execution halted
这是我的测试文件的样子(这里是 link 到 GitHub https://github.com/ayalaallon/prepdat
skip_on_cran()
library(prepdat)
data("finalized_stroopdata")
data("stroopdata")
context("Finalized table")
test_finalized_stroopdata <- prep(
dataset = stroopdata
, file_name = NULL
, file_path = NULL
, id = "subject"
, within_vars = c("block", "target_type")
, between_vars = c("order")
, dvc = "rt"
, dvd = "ac"
, keep_trials = NULL
, drop_vars = c()
, keep_trials_dvc = "raw_data$rt > 100 & raw_data$rt < 3000 & raw_data$ac == 1"
, keep_trials_dvd = "raw_data$rt > 100 & raw_data$rt < 3000"
, id_properties = c()
, sd_criterion = c(1, 1.5, 2)
, percentiles = c(0.05, 0.25, 0.75, 0.95)
, outlier_removal = 2
, keep_trials_outlier = "raw_data$ac == 1"
, decimal_places = 0
, notification = TRUE
, dm = c()
, save_results = FALSE
, results_name = "results.txt"
, results_path = NULL
, save_summary = FALSE
)
test_that("Finialized table is correct", {
expect_equal(test_finalized_stroopdata, finalized_stroopdata)
})
我该如何解决这个问题?
非常感谢任何帮助,
阿亚拉
您使用 skip_on_cran
不正确。它需要包含在您的 test_that
块中:
test_that("Finialized table is correct", {
skip_on_cran()
expect_equal(test_finalized_stroopdata, finalized_stroopdata)
})