test your tests with r metaprogramming n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Test your tests with R metaprogramming PowerPoint Presentation
Download Presentation
Test your tests with R metaprogramming

Loading in 2 Seconds...

play fullscreen
1 / 8

Test your tests with R metaprogramming - PowerPoint PPT Presentation


  • 115 Views
  • Uploaded on

Test your tests with R metaprogramming. Tom Taverner, Chris Campbell Mango Solutions. Two ideas for testing software. Black box testing ( RUnit and testthat ) shows broken code Clear box testing shows faulty/dead/unreachable code. R based test coverage.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Test your tests with R metaprogramming' - leona


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
test your tests with r metaprogramming

Test your tests with R metaprogramming

Tom Taverner, Chris Campbell

Mango Solutions

two ideas for testing software
Two ideas for testing software
  • Black box testing (RUnit and testthat) shows broken code
  • Clear box testing shows faulty/dead/unreachable code
r based test coverage
R based test coverage
  • Code coverage is the degree to which code is tested by a particular test suite
  • Want to find which code is not executed
  • We developed a code coverage testing tool

Overall report of coverage %

R package

HTML code coverage viewer

Unit test suite

example
Example
  • Function ‘trapezium’ is read in but not called by the unit test suite
  • In practise we found 90-100% coverage in production code
  • Error handling code is especially hard to test
the instrumentation algorithm
The instrumentation algorithm
  • Rewrites code to put trace calls everywhere
  • Uses R 3.0’s alternate parser

y <- x + 10

`_1` <- `_2` + 10

`_1` <-

{trace(); `_2` + 10}

y <-

{trace(2); x + 10}

1. Get parse table mapping symbols to unique ID

2. Replace symbols by UIDs

3. Insert trace calls

4. Instrument trace calls and replace UIDs by symbols

aims for the near future
Aims for the near future
  • Put on Github
  • Integrate with CI tools
  • Take inspiration from Java tools (clover)
  • Other types of coverage?