Skip to content

bioc/biocroxytest

Repository files navigation

biocroxytest biocroxytest website

Lifecycle: experimental R-CMD-check Codecov test coverage PRs Welcome GitHub issues GitHub pulls

The biocroxytest package is a novel tool that enhances the efficiency of test writing in R, particularly for Bioconductor software packages. It leverages the structure of roxygen2 for test writing, which improves readability, code organization, and integrates seamlessly with package documentation.

In Bioconductor, daily tests are run as part of the nightly builds, with a maximum limit of 40 minutes per package. For tests that exceed this limit, developers can set up “long tests” and add their package to the Bioconductor Long Tests builds. However, traditionally separating tests and long tests can be cumbersome.

biocroxytest addresses this issue by introducing a new roclet, @longtests, inspired by roxytest. This allows developers to document and store long tests directly within their roxygen2 comments. By using the @longtests roclet, extensive tests are run and checked regularly without impacting the efficiency of the daily build process.

The @longtests roclet provides a dedicated space for extensive tests, ensuring they are easily accessible and well-documented. This not only improves the package’s reliability but also its maintainability. Thus, biocroxytest contributes to the creation of robust, reliable, and efficient Bioconductor packages.

Installation instructions

Get the latest stable R release from CRAN. Then install biocroxytest from Bioconductor using the following code:

# Not yet on Bioconductor
# if (!requireNamespace("BiocManager", quietly = TRUE)) {
#     install.packages("BiocManager")
# }
# 
# BiocManager::install("biocroxytest")

And the development version from GitHub with:

BiocManager::install("xec-cm/biocroxytest")

Example

Here is how you can use biocroxytest to create a new package with long tests:

To use the package in your own package you do not need to add any additional dependencies in your package’s DESCRIPTION file. Simply add the following lines to your package’s DESCRIPTION file (along with Suggests: testthat):

Roxygen: list(roclets = c("namespace", "rd", "biocroxytest::longtests_roclet"))

Then add @longtests to the roxygen comments of the functions you want to test. For example, if the file R/functions.R contains this code:

#' A function to do x
#' 
#' @param x A number
#' 
#' @longtests 
#' expect_equal(foo(2), sqrt(2))
#' expect_error(foo("a string"))
#' 
#' @return something
foo <- function(x) {
  return(sqrt(x))
}

#' A function to do y
#' 
#' @param x Character vector
#' @param y Character vector
#' 
#' @longtests 
#' expect_equal(bar("A", "B"), paste("A", "B", sep = "/"))
#' 
#' @export
bar <- function(x, y) {
  paste0(x, "/", y)
}

Then roxygen2::roxygenise() will generate (with the longtests_roclet roclet) the file longtests/test-biocroxytest-tests-functions.R with this content:

# Generated by biocroxytest: do not edit by hand!

# File R/functions.R: @longtests

test_that("Function foo() @ L11", {
  expect_equal(foo(2), sqrt(2))
  expect_error(foo("a string"))
})


test_that("Function bar() @ L27", {
  expect_equal(bar("A", "B"), paste("A", "B", sep = "/"))
})

Contributing

Code of Conduct

Please note that the biocroxytest project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

This is a read-only mirror of the git repos at https://bioconductor.org

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages