"include/vscode:/vscode.git/clone" did not exist on "8a19834a6644ca2598704fd1208a4b50cbedd02d"
Unverified Commit f449a78d authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] Added instructions for generating R test coverage (#2664)

parent 2048b139
......@@ -321,6 +321,9 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
**/coverage.html
**/coverage.html.zip
R-package/tests/testthat/Rplots.pdf
# Translations
*.mo
......
......@@ -126,6 +126,30 @@ Please visit [demo](https://github.com/microsoft/LightGBM/tree/master/R-package/
* [Leaf (in)Stability](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/leaf_stability.R)
* [Weight-Parameter Adjustment Relationship](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/weight_param.R)
Testing
-------
The R package's unit tests are run automatically on every commit, via integrations like [Travis CI](https://travis-ci.org/microsoft/LightGBM/) and [Azure DevOps](https://dev.azure.com/lightgbm-ci/lightgbm-ci/_build). Adding new tests in `R-package/tests/testthat` is a valuable way to improve the reliability of the R package.
When adding tests, you may want to use test coverage to identify untested areas and to check if the tests you've added are covering all branches of the intended code.
The example below shows how to generate code coverage for the R package on a macOS or Linux setup, using `gcc-8` to compile `LightGBM`. To adjust for your environment, swap out the 'Install' step with [the relevant code from the instructions above](#install).
```shell
# Install
export CXX=/usr/local/bin/g++-8
export CC=/usr/local/bin/gcc-8
Rscript build_r.R
# Get coverage
rm -rf lightgbm_r/build
Rscript -e " \
coverage <- covr::package_coverage('./lightgbm_r', quiet=FALSE);
print(coverage);
covr::report(coverage, file = file.path(getwd(), 'coverage.html'), browse = TRUE);
"
```
External (Unofficial) Repositories
----------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment