i have started make unit-tests functions in r, using svunit (docs). have done test functions in file, ones in file, , have created maintest, call tests. project looks this:
proj |-src | |-functions1 (containing functions) | |-functions2 (containing other functions) | |-functions3 (containing more functions) | |-mainfile (here call functions in files above) |-tests |-functions1test (containing tests functions in functions1 file) |-functions2test (containing tests functions in functions2 file) |-functions3test (containing tests functions in functions3 file) |-maintest (containing function runs tests) a functionsxtest file looks this:
source('functionsx.r') test(fun1) <- function(){ # call fun1 function , check result } test(fun2) <- function(){ # call fun2 function , check result } # ... functions1tests <- svsuite(svsuitelist()) # here the maintests looks this:
library('svunit') source('functions1tests.r') source('functions1tests.r') source('functions1tests.r') launchtests <- function(){ clearlog() runtest(functions1tests) runtest(functions2tests) runtest(functions3tests) log() } i thought last line @ end of file functionsxtest.r grouping unit tests in variable, seems grouping tests in variable, functions1tests containing tests functions in functions1.r, , functions2tests containing tests in functions1.r , functions2.r. there possibility have tests in file grouped in variable , run tests on each variable, easier find problematic test?
i have found if add names of tests in svsuite, separates different tests, doing:
functions1tests <- svsuite("fun1", "fun2") on last line of functionsxtest.r file, functions2tests not contain tests functions1test.r.
but wondering if there possibility split test in log, because display like:
> launchtests() = svunit test suite run in less 0.1 sec with: * testfun1 ... ok * testfun1 ... ok * testfun2 ... ok * ... == testfun1 (in runitfunctions1test.r) run in less 0.1 sec: ok //pass: 7 fail: 0 errors: 0// == testfun1 (in runitfunctions2test.r) run in less 0.1 sec: ok //pass: 4 fail: 0 errors: 0// == testfun2 (in runitfunctions1test.r) run in less 0.1 sec: ok //pass: 10 fail: 0 errors: 0// ...
Comments
Post a Comment