Skip to content

expect_error fails for java Exceptions #964

Closed
@pfistfl

Description

@pfistfl

since version 2.3.0, tests that check for java Exceptions fail.

On 2.2.0:
remotes::install_version("testthat", "2.2.0")

library(rJava)
library(testthat)
.jinit()
.jnew("hello/world", check = TRUE)
#> Error in .jnew("hello/world", check = TRUE): java.lang.ClassNotFoundException

expect_error(.jnew("hello/world", check = TRUE))

Created on 2019-11-08 by the reprex package (v0.3.0)

On 2.3.0:
remotes::install_version("testthat", "2.3.0")

library(rJava)
library(testthat)
.jinit()
.jnew("hello/world", check = TRUE)
#> Error in .jnew("hello/world", check = TRUE): java.lang.ClassNotFoundException

expect_error(.jnew("hello/world", check = TRUE))
#> Error in ._jobjRef_dollar(x[["jobj"]], name): no field, method or inner class called 'trace'

Created on 2019-11-08 by the reprex package (v0.3.0)

I digged a little deeper, and the reason is most likely that rlang::cnd_entrace used in capture_error tries to access the $trace slot, which does prompt a java Error.

Is there another method intended to test for Exceptions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions