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
• 11,360 points
769 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,840 points

Related Questions In Data Analytics

+2 votes
2 answers
+1 vote
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
• 52,360 points
2,031 views
+1 vote
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,840 points
2,318 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
• 52,360 points
4,631 views
+2 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
• 52,360 points
9,356 views
+1 vote
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
• 52,360 points
478 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,840 points
2,772 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,840 points
1,402 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP