当我运行单元测试(使用runTests())时,我希望输出两个“ TRUE”,而不仅仅是一个“ TRUE”。我该如何利用这里的内容来实现这一点(并非我的所有代码都出于简洁目的)?
runTests <- function()
{
test_oneWordCounty()
test_twoWordCounty()
} # runTests
#TEST1
test_oneWordCounty <- function() {
#extra code... here
return(
checkEquals(stateAbbr, "CA") #check the state abbreviation is correct
) }
#TEST2
test_twoWordCounty <- function() {
#extra code... here
return(
checkEquals(stateZip, "California"), #check the state identification is correct
)) }
答案 0 :(得分:0)
一个函数只能返回一个对象。但是,这很容易解决,因为这仅意味着您需要将要返回的所有内容组合到一个对象中。例如:
runTests <- function()
{
c(test_oneWordCounty(),
test_twoWordCounty()
)
} # runTests