testthat icon indicating copy to clipboard operation
testthat copied to clipboard

`label` does not work in test_local

Open JBGruber opened this issue 3 years ago • 0 comments

I would like to use the label argument as I run a test on several similar function in a loop, which means I have to manually go in an check which iteration failed without a label. Here is an example:

test_that("Test devtools", {
  expect_false({
    TRUE
  }, label = "My Label")
})

When I run just this test, it works as intended:

library(testthat)
test_that("Test devtools", {
  expect_false({
    TRUE
  }, label = "My Label")
})
#> ── Failure (<text>:3:3): Test devtools ─────────────────────────────────────────
#> My Label is not FALSE
#> 
#> `actual`:   TRUE 
#> `expected`: FALSE
#> Error in `reporter$stop_if_needed()`:
#> ! Test failed

Created on 2022-09-26 by the reprex package (v2.0.1)

Yet it fails with an unused argument error when run in testthat::test_local:

testthat::test_local()
#> ✔ | F W S  OK | Context
#> 
#> ⠏ |         0 | collect                                                         
#> ⠋ |         1 | collect                                                         
#> ⠙ |         2 | collect                                                         
#> ⠹ |         3 | collect                                                         
#> ⠸ |         4 | collect                                                         
#> ✔ |         5 | collect [3.4s]
#> 
#> ⠏ |         0 | cookies                                                         
#> ⠋ |         1 | cookies                                                         
#> ✔ |         1 | cookies [0.4s]
#> 
#> ⠏ |         0 | deliver                                                         
#> ⠋ |         1 | deliver                                                         
#> ⠸ |         4 | deliver                                                         
#> ⠼ |         5 | deliver                                                         
#> ⠴ |         6 | deliver                                                         
#> ⠦ |         7 | deliver                                                         
#> ✔ |         7 | deliver [3.2s]
#> 
#> ⠏ |         0 | misc                                                            
#> ✔ |         4 | misc
#> 
#> ⠏ |         0 | scrapers                                                        
#> ⠼ |        15 | scrapers                                                        
#> ⠦ |        27 | scrapers                                                        
#> ✖ | 1      29 | scrapers [0.2s]
#> ────────────────────────────────────────────────────────────────────────────────
#> Error (test-scrapers.R:27:3): Test Label
#> Error in `expect_false({
#>     FALSE
#> }, label = "My Label")`: unused argument (label = "My Label")
#> ────────────────────────────────────────────────────────────────────────────────
#> 
#> ══ Results ═════════════════════════════════════════════════════════════════════
#> Duration: 7.3 s
#> 
#> [ FAIL 1 | WARN 0 | SKIP 0 | PASS 46 ]
#> Error: Test failures

Created on 2022-09-26 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       EndeavourOS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language
#>  collate  en_GB.UTF-8
#>  ctype    en_GB.UTF-8
#>  tz       Europe/Berlin
#>  date     2022-09-26
#>  pandoc   2.19.2 @ /usr/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version    date (UTC) lib source
#>    assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.2.0)
#>    brio          1.1.3      2021-11-30 [1] CRAN (R 4.2.0)
#>    cli           3.3.0      2022-04-25 [1] CRAN (R 4.2.0)
#>    crayon        1.5.1      2022-03-26 [1] CRAN (R 4.2.0)
#>    curl          4.3.2      2021-06-23 [1] CRAN (R 4.2.0)
#>    DBI           1.1.3      2022-06-18 [1] CRAN (R 4.2.1)
#>    desc          1.4.1      2022-03-06 [1] CRAN (R 4.2.0)
#>    digest        0.6.29     2021-12-01 [1] CRAN (R 4.2.0)
#>    dplyr         1.0.9      2022-04-28 [1] CRAN (R 4.2.0)
#>    ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.2.0)
#>    evaluate      0.16       2022-08-09 [1] CRAN (R 4.2.1)
#>    fansi         1.0.3      2022-03-24 [1] CRAN (R 4.2.0)
#>    fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.2.0)
#>    fs            1.5.2      2021-12-08 [1] CRAN (R 4.2.0)
#>    generics      0.1.3      2022-07-05 [1] CRAN (R 4.2.1)
#>    glue          1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
#>    highr         0.9        2021-04-16 [1] CRAN (R 4.2.0)
#>    hms           1.1.2      2022-08-19 [1] CRAN (R 4.2.1)
#>    htmltools     0.5.3      2022-07-18 [1] CRAN (R 4.2.1)
#>    httr          1.4.4      2022-08-17 [1] CRAN (R 4.2.1)
#>    knitr         1.39       2022-04-26 [1] CRAN (R 4.2.0)
#>    lifecycle     1.0.1      2021-09-24 [1] CRAN (R 4.2.0)
#>    lubridate     1.8.0      2021-10-07 [1] CRAN (R 4.2.0)
#>    magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
#>  P paperboy    * 0.0.3.9000 2022-09-26 [?] load_all()
#>    pillar        1.8.1      2022-08-19 [1] CRAN (R 4.2.1)
#>    pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
#>    pkgload       1.3.0      2022-06-27 [1] CRAN (R 4.2.1)
#>    prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.2.0)
#>    progress      1.2.2      2019-05-16 [1] CRAN (R 4.2.0)
#>    purrr         0.3.4      2020-04-17 [1] CRAN (R 4.2.0)
#>    R.cache       0.16.0     2022-07-21 [1] CRAN (R 4.2.1)
#>    R.methodsS3   1.8.2      2022-06-13 [1] CRAN (R 4.2.1)
#>    R.oo          1.25.0     2022-06-12 [1] CRAN (R 4.2.1)
#>    R.utils       2.12.0     2022-06-28 [1] CRAN (R 4.2.1)
#>    R6            2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
#>    Rcpp          1.0.9      2022-07-08 [1] CRAN (R 4.2.1)
#>    reprex        2.0.1      2021-08-05 [1] CRAN (R 4.2.0)
#>    rlang         1.0.4      2022-07-12 [1] CRAN (R 4.2.1)
#>    rmarkdown     2.14       2022-04-25 [1] CRAN (R 4.2.0)
#>    rprojroot     2.0.3      2022-04-02 [1] CRAN (R 4.2.0)
#>    rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.2.0)
#>    rvest         1.0.3      2022-08-19 [1] CRAN (R 4.2.1)
#>    selectr       0.4-2      2019-11-20 [1] CRAN (R 4.2.0)
#>    sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
#>    stringi       1.7.8      2022-07-11 [1] CRAN (R 4.2.1)
#>    stringr       1.4.1      2022-08-20 [1] CRAN (R 4.2.1)
#>    styler        1.7.0      2022-03-13 [1] CRAN (R 4.2.1)
#>    testthat    * 3.1.4      2022-04-26 [1] CRAN (R 4.2.0)
#>    tibble        3.1.8      2022-07-22 [1] CRAN (R 4.2.1)
#>    tidyr         1.2.0      2022-02-01 [1] CRAN (R 4.2.0)
#>    tidyselect    1.1.2      2022-02-21 [1] CRAN (R 4.2.0)
#>    triebeard     0.3.0      2016-08-04 [1] CRAN (R 4.2.0)
#>    urltools      1.7.3      2019-04-14 [1] CRAN (R 4.2.0)
#>    utf8          1.2.2      2021-07-24 [1] CRAN (R 4.2.0)
#>    vctrs         0.4.1      2022-04-13 [1] CRAN (R 4.2.0)
#>    withr         2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
#>    xfun          0.31       2022-05-10 [1] CRAN (R 4.2.0)
#>    xml2          1.3.3      2021-11-30 [1] CRAN (R 4.2.0)
#>    yaml          2.3.5      2022-02-21 [1] CRAN (R 4.2.0)
#> 
#>  [1] /home/johannes/R/x86_64-pc-linux-gnu-library/4.2
#>  [2] /usr/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

JBGruber avatar Sep 26 '22 10:09 JBGruber