Some of your tests are quite large:
test_that("Output errors", {
# generate an output
data_split <- train_test_split(X, y)
# check the output type
expect_is(data_split, "list")
# check the output length
expect_equal(length(data_split), 4)
# assign outputs
X_train <- data_split[[1]]
X_test <- data_split[[2]]
y_train <- data_split[[3]]
y_test <- data_split[[4]]
# check the output types of elements in the list
expect_true(is.data.frame(X_train) | is.atomic(X_train))
expect_true(is.data.frame(X_test) | is.atomic(X_test))
expect_true(is.data.frame(y_train) | is.atomic(y_train))
expect_true(is.data.frame(y_test) | is.atomic(y_test))
# check if the dimension equals between split data and origianl data
# check X and X_train, X_test
expect_equal(get_nrows(X), get_nrows(X_train)+get_nrows(X_test))
# check y and y_train, y_test
expect_equal(get_nrows(y), get_nrows(y_train)+get_nrows(y_test))
})
You should split this up into 4 different test_that statements, using what you currently have as comments as the test/error messages. This strategy makes your tests more useful and efficient, as it's much easier to pinpoint what exactly is broken with more, smaller tests.
Some of your tests are quite large:
You should split this up into 4 different
test_thatstatements, using what you currently have as comments as the test/error messages. This strategy makes your tests more useful and efficient, as it's much easier to pinpoint what exactly is broken with more, smaller tests.