This repository contains a comprehensive testing framework for the colocboost R package. The framework is designed to ensure the reliability and correctness of package functionality through automated testing.
Our unit testing setup is managed by pixi
. Please follow the instructions at https://pixi.sh/latest/#installation if you have not already installed pixi
.
In the root of this repository, run the helper script to create a pixi.toml file. This file is deliberately ignored in .gitignore
because it is ephemeral and will be regenerated whenever CI is run.
bash
.github/workflows/create_toml_from_yaml.sh $(pwd)
Run all tests with a pixi
task:
bash
pixi run devtools_test
or test one file using pixi run
:
bash
pixi run R -e 'devtools::test_active_file("tests/testthat/test_colocboost.R")'
testthat/
: Directory containing test filestest_package.R
: Tests for basic package functionalitytest_colocboost.R
: Tests for the main colocalization functionstest_inference.R
: Tests for the post inference functionstest_utils.R
: Tests for utility functionstest_model.R
: Tests for model fitting and prediction functions.github/workflows/
: GitHub Actions workflow configurationsWhen adding new functionality to the colocboost package, corresponding tests should be added to maintain test coverage. Follow these steps:
Example test:
test_that("new_function produces expected output", {
# Arrange
input_data <- prepare_test_data()
# Act
result <- new_function(input_data)
# Assert
expect_equal(result$some_value, expected_value)
expect_true(is.data.frame(result$data))
})
The covr
package is used to measure test coverage, which indicates what percentage of the code is being tested.
To generate a test coverage report:
pixi run codecov
This testing framework includes GitHub Actions workflows that automatically run the tests on every pull request. The workflows test the package on Linux and macOS to ensure cross-platform compatibility.
The workflow is defined in .github/workflows/ci.yaml
and automatically runs:
- R CMD check
- Test coverage reporting with codecov.io
Test results and coverage statistics are available on the GitHub Actions page after each pull request.
For more information, check the testthat documentation.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.