# Test package startup messages library(testthat) test_that(".onAttach displays startup message", { # Capture the message when the package is attached # This is tricky to test directly, but we can verify the function exists expect_true(exists(".onAttach", where = asNamespace("Athlytics"))) # Test that the function can be called without error # Note: .onAttach is called automatically when the package is loaded # We'll just verify it doesn't throw an error ns <- asNamespace("Athlytics") expect_silent({ # Create a mock libname and pkgname libname <- .libPaths()[1] pkgname <- "Athlytics" # The function should work without error even if called manually # though in practice it's only called by R during package loading if (exists(".onAttach", where = ns)) { # We don't actually call it as it would print to console # Just verify it exists and is a function fn <- get(".onAttach", envir = ns) expect_type(fn, "closure") } }) })