GitHub - xec-cm/biocroxytest: The biocroxytest package is a tool that enhances the efficiency of test writing in Bioconductor software packages. (original) (raw)
biocroxytest 
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 theirroxygen2_ 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 fromCRAN. Then install biocroxytest
fromBioconductor using the following code:
Not yet on Bioconductor
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
BiocManager::install("biocroxytest")
And the development version fromGitHub 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
- If you think you have encountered a bug, please submit an issue.
- Either way, learn how to create and share areprex(a minimal, reproducible example), to clearly communicate about your code.
- Working on your first Pull Request? You can learn how from this _free_series How to Contribute to an Open Source Project on GitHub
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.