Error sayimg "Executing test function test.should_error ... Timing stopped at: 0 0 0 " in R

0 votes

My test.R file:

context("The context")

test_that('should pass',function(){
    expect_equal(42,42)
})

test_that('should fail',function(){
    expect_equal(43,42)
})

test_that('should error',function(){
    stop()
})

When I write analogous tests using Runit:

test.should_pass <- function(){
    checkEquals(42,42)
}

test.should_fail <- function(){
    checkEquals(43,42)
}

test.should_error <- function(){
    stop()
}

I get the output:

> results <- runTestFile('tests.r')

Executing test function test.should_error  ... Timing stopped at: 0 0 0 
Error in func() : 
    done successfully.


Executing test function test.should_fail  ... Timing stopped at: 0 0 0.001 
Error in checkEquals(43, 42) : Mean relative difference: 0.02325581
done successfully.



Executing test function test.should_pass  ...  done successfully.

> results
Number of test functions: 3 
Number of errors: 1 
Number of failures: 1
Nov 12, 2018 in Data Analytics by Ali
• 10,430 points
61 views

1 answer to this question.

0 votes

In your testthat tests you declare an anonymous function like so:

function() {
  expect_equal(43,42)
}

and change you test.R file:

context("The context")

test_that('should pass', {
  expect_equal(42,42)
})

test_that('should fail', {
  expect_equal(43,42)
})

test_that('should error', {
  stop()
})
answered Nov 12, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
1 answer

"subscript out of bounds" error in while executing simple R program

This is caused by trying to access ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 42,410 points
129 views
0 votes
1 answer

Error saying "could not find function "shinyUI"" in shiny R

Its a small spelling mistake that you've ...READ MORE

answered Nov 28, 2018 in Data Analytics by Maverick
• 10,040 points
469 views
0 votes
1 answer

": cannot open the connection" Error in R

There can be two reasons for this ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 42,410 points
597 views
0 votes
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 42,410 points
2,137 views
0 votes
1 answer

What does “replacement has” Error mean?

This error occurs when one tries to ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 42,410 points
49 views
0 votes
1 answer

Errors saying "Error: unexpected '}' in "}"

This is a syntax error: Enclose your if ...READ MORE

answered Nov 8, 2018 in Data Analytics by Maverick
• 10,040 points
492 views
0 votes
1 answer

Error with shortest.path function in R

you have a directed graph. The shortest.paths function will ...READ MORE

answered Nov 12, 2018 in Data Analytics by Maverick
• 10,040 points
66 views
0 votes
1 answer