tests/doRUnit.R

if( require( "RUnit", quietly=TRUE ) ) {
  pkg <- "xmapbridge"

  if( Sys.getenv( "RCMDCHECK" ) == "FALSE" ) {
    path <- file.path( getwd(), "..", "inst", "unitTests" )
  }
  else {
    path <- system.file( package=pkg, "unitTests" )
  }

  cat( "\nRunning unit tests\n" )
  print( list( pkg=pkg, getwd=getwd(), pathToUnitTests=path ) )
  library( package=pkg, character.only=TRUE )
 
  testSuite <- defineTestSuite( name=paste( pkg, "unit testing" ), dirs=path )
  tests <- runTestSuite( testSuite )
 
  pathReport <- file.path( path, "report" )
 
  cat( "------------------- UNIT TEST SUMMARY ---------------------\n\n" )
  printTextProtocol( tests, showDetails=FALSE )
  printTextProtocol( tests, showDetails=FALSE, fileName=paste( pathReport, "Summary.txt", sep="" ) )
  printTextProtocol( tests, showDetails=TRUE,  fileName=paste( pathReport, ".txt", sep="" ) )
 
  printHTMLProtocol( tests, fileName=paste( pathReport, ".html", sep="" ) )
 
  tmp <- getErrors( tests )
  if( tmp$nFail > 0 | tmp$nErr > 0 ) {
    stop( paste( "\n\nunit testing failed (#test failures: ", tmp$nFail, ", #R errors: ",  tmp$nErr, ")\n\n", sep="" ) )
  }
} else {
  warning( "cannot run unit tests -- package RUnit is not available" )
}

Try the xmapbridge package in your browser

Any scripts or data that you put into this service are public.

xmapbridge documentation built on Nov. 8, 2020, 6:46 p.m.