Skip to content
Jess Panni By Jess Panni Principal I
Automating R Unit Tests With Azure DevOps

I recently demonstrated how it was possible to automate the deployment of R models to Azure Machine Learning through Azure DevOps. Of course, this is only part of the story; what about testing? It is important to ensure that all production code is adequately tested, and R is no different. Writing unit tests for R models is straight-forward using the popular testthat R package. With the help of some PowerShell it is possible to run these tests as part a continuous integration build and deployment pipeline.

Check out the video to see it in action.

Automating R Unit Tests With VSTS from endjin on Vimeo.

FAQs

Why should data scientists write unit tests for R models? Production R code deserves the same quality assurance as any other code. Unit tests catch regression errors when models are updated, validate edge cases in data transformations, and provide documentation of expected behaviour. The testthat package makes writing R tests straightforward with familiar assertion patterns.
How do you run R unit tests in an Azure DevOps pipeline? PowerShell scripts bridge the gap between Azure DevOps build agents and R execution. The scripts invoke R with testthat to run your test suite and translate the results into a format Azure DevOps understands. This enables R tests to appear alongside other test results and fail the build when tests fail.

Jess Panni

Principal I

Jess Panni

Jess has over 25 years' experience helping companies succeed through the smart use of technology. He spent most of his career working for leading Microsoft partners across the UK and Australia and was Principal at endjin, working with clients to envision and execute disciplined innovation programmes.

Jess worked at endjin between 2015-2020.