diff --git a/DESCRIPTION b/DESCRIPTION index 590cad835..a39f6c3f0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ Depends: Imports: brio, callr (>= 3.5.1), - cli (>= 2.2.0), + cli (>= 3.1.1), crayon (>= 1.3.4), desc, digest, diff --git a/NEWS.md b/NEWS.md index a7e268445..87a6d60b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -52,6 +52,9 @@ * When a snapshot changes the hint also mentions that you can use `snapshot_review()` (#1500, @DanChaltiel) and the message tells you what variant is active (#1540). +* JUnit reporter now includes skip messages/reasons (@rfineman, #1507). + +* Test results show hyperlinks to failed expectation when supported (#1544). # testthat 3.1.1 diff --git a/R/expectation.R b/R/expectation.R index 8318b42c9..dd416d6ac 100644 --- a/R/expectation.R +++ b/R/expectation.R @@ -260,11 +260,16 @@ expectation_location <- function(x) { if (is.null(x$srcref)) { "???" } else { - filename <- attr(x$srcref, "srcfile")$filename + srcfile <- attr(x$srcref, "srcfile") + filename <- srcfile$filename if (identical(filename, "")) { paste0("Line ", x$srcref[1]) } else { - paste0(basename(filename), ":", x$srcref[1], ":", x$srcref[2]) + cli::style_hyperlink( + paste0(basename(filename), ":", x$srcref[1], ":", x$srcref[2]), + paste0("file://", file.path(srcfile$wd, filename)), + params = c(line = x$srcref[1], col = x$srcref[2]) + ) } } } diff --git a/R/snapshot.R b/R/snapshot.R index c64a80235..7a079f6ae 100644 --- a/R/snapshot.R +++ b/R/snapshot.R @@ -401,9 +401,14 @@ snapshot_accept_hint <- function(variant, file) { name <- file.path(variant, file) } + code_accept <- paste0("snapshot_accept('", name, "')") + code_review <- paste0("snapshot_review('", name, "')") + link <- function(code) { + cli::style_hyperlink(code, paste0("rstudio:run:testthat::", code)) + } paste0( - "* Run `snapshot_accept('", name, "')` to accept the change\n", - "* Run `snapshot_review('", name, "')` to interactively review the change" + "* Run `", link(code_accept), "` to accept the change\n", + "* Run `", link(code_review), "` to interactively review the change" ) }