Since the utility of this function isn't very clear, here's a possible use case. It isn't life-changing, but I think it qualifies as a minor perk.
When you want to test a new function, it can be quite useful to write down all the tests that you can think of in one go. Rather than worrying about how each test needs to be implemented, you just want a placeholder that fails, in order to let you know that you haven't written that test yet. After you've decided upon each test, you can go back and replace the fails with real tests.
You could just stick a stop("Not done this yet") in your test - that will show as an error rather than a failure in the test runner. Semantically I find the idea of a failure being conjured from thin air quite disturbing, whereas saying 'stop!' seems more natural. HMMV.
There's been a request for a
testthat, that just makes a test fail.
I had a go at writing one, for possible inclusion in the package.
' Makes a testfail
' The fail function forces a test to fail.
' @param message a string to display.
' @param infoextra information to be included in the message (useful when writing tests in loops).
fail <- function(message = "Failure has been forced.", info = NULL)
info = info,
Usage is, for example,
The text was updated successfully, but these errors were encountered: