library(testthat) # Simple test: check if the function runs on the given dataset and returns results test_that("fit_and_plot_models works without errors", { # Use the built-in iris dataset for testing data(iris) # Create a simple formula to predict Species formula <- Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width # Call the fit_and_plot_models function and check that it does not error result <- fit_and_plot_models(iris, formula, ntree = 500) # Check that the returned value is a list containing prediction results expect_type(result, "list") expect_named(result, c("rf_predictions", "svm_predictions", "decision_tree_predictions", "logistic_predictions")) # Check that predictions from each model are not empty expect_true(length(result$rf_predictions) > 0) expect_true(length(result$svm_predictions) > 0) expect_true(length(result$decision_tree_predictions) > 0) expect_true(length(result$logistic_predictions) > 0) })