Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206235

'testthat', how should I interpret this failure?

$
0
0

I want to use 'testthat' to add tests to my package.

This is my test-file:

library(RBaseX)

test_that("Credentials are accepted", {
  skip_unless_socket_available()

  expect_error(BasexClient$new("localhost", 1984L, username = "admin", password = "denied"), "Access denied")

  Session <- BasexClient$new("localhost", 1984L, username = "admin", password = "admin")
  expect_equal(class(Session)[[1]], "BasexClient")
})

skip_unless_socket_available is defined in a separate helper.R-file:

skip_unless_socket_available <- function() {
  tryCatch({
    Socket <- socketConnection(host = "localhost", 1984,
                           open = "w+b", server = FALSE, blocking = TRUE, encoding = "utf-8")
    close(Socket)
    TRUE
  }, error = function(e) {
    skip(paste0("basexserver not available:\n'", conditionMessage(e), "'"))
  })
}

When the program is executed I get this output:

Loading RBaseX
Testing RBaseX
✓ |  OK F W S | Context
✓ |   2       | test_RbaseX [0.2 s]
⠹ |   2 1     | test_RbaseX
══ Results ═══════════════════════════════
Duration: 0.3 s

OK:       2
Failed:   1
Warnings: 0
Skipped:  0

No matter what I do, I still get 1 failure. Both exceptions, however, are handled correctly.

How should I act upon this failure?

Ben

After inserting 3 contexts() in test_RBaseX.R, I now get this output:

Loading RBaseX
Testing RBaseX
✓ |  OK F W S | Context
✓ |   2       | Access [0.1 s]
✓ |   2       | Create Session [0.1 s]
⠏ |   0       | Check setter/getter (and BasexClient$Execute()) 
✓ |   2       | Check setter/getter (and BasexClient$Execute())
⠏ |   0       | Intercept set/get is handled correctlyDatabase 'TestOpen' is niet gevonden. 
Database 'TestOpen' is niet gevonden. 
Database 'TestOpen' is niet gevonden. 
✓ |   1       | Intercept set/get is handled correctly
⠙ |   1 1     | Intercept set/get is handled correctly
══ Results ════════════════════════════════════════════
Duration: 0.4 s

OK:       7
Failed:   1
Warnings: 0
Skipped:  0

All tests give the expected result but then 1 failure is added. I still haven't seen any indication why.

Does this help?

Ben
(By the way, thanks to these testing-activities, I found and fixed serveral errors :-))


Viewing all articles
Browse latest Browse all 206235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>