Skip to content

expect_no_error() doesn't count? #2037

Closed

Description

@jonthegeek

With testthat 3.2.2, expect_no_error() tests are skipped as "empty test".

library(testthat)
test_that("This definitely isn't empty", {
  expect_no_error({
    mean(1:10)
  })
})
#> ── Skip: This definitely isn't empty ───────────────────────────────────────────
#> Reason: empty test

Created on 2024-12-11 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 (2024-10-31 ucrt)
#>  os       Windows 11 x64 (build 26100)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/Chicago
#>  date     2024-12-11
#>  pandoc   3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  brio          1.1.5   2024-04-24 [1] CRAN (R 4.4.1)
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.1)
#>  desc          1.4.3   2023-12-10 [1] CRAN (R 4.4.1)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.1   2024-10-10 [1] CRAN (R 4.4.1)
#>  fansi         1.0.6   2023-12-08 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.1)
#>  fs            1.6.5   2024-10-30 [1] CRAN (R 4.4.1)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
#>  knitr         1.49    2024-11-08 [1] CRAN (R 4.4.2)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.1)
#>  pillar        1.9.0   2023-03-22 [1] CRAN (R 4.4.1)
#>  pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.4.1)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.1)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.1)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.1)
#>  rmarkdown     2.29    2024-11-04 [1] CRAN (R 4.4.1)
#>  rprojroot     2.0.4   2023-11-05 [1] CRAN (R 4.4.1)
#>  rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.1)
#>  testthat    * 3.2.2   2024-12-10 [1] CRAN (R 4.4.2)
#>  utf8          1.2.4   2023-10-22 [1] CRAN (R 4.4.1)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.1)
#>  waldo         0.6.1   2024-11-07 [1] CRAN (R 4.4.2)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.4.1)
#>  xfun          0.49    2024-10-31 [1] CRAN (R 4.4.1)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.1)
#> 
#>  [1] C:/Users/Jon Harmon/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.2/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Activity

  1. orichters commented on Dec 30, 2024

    @orichters

    Same with expect_no_warning.

    test_that("expect_no_warning is not empty", {
      expect_no_warning(a <- 0)
    })
    
    ── Skip: expect_no_warning is not empty ───
    Reason: empty test
    

    Might be caused by #2010, @hadley?

  2. johnomics commented on Jan 6, 2025

    @johnomics

    All expect_no functions are passing silently. Commit 4e3446c attempts to fix this but it doesn't look like it works - the new tests added to test-expect-no-condition.R in this commit are skipped (using a local clone of the main branch):

    > packageVersion("testthat")
    [1] ‘3.2.2.9000’
    > devtools::test(filter = "expect-no-condition")
    ℹ Testing testthat
    Starting 1 test process
    ✔ | F W  S  OK | Context
    ✔ |      1  18 | expect-no-condition [1.3s]
    
    ══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
    Duration: 3.0 s
    
    ── Skipped tests (1) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    • empty test (1): test-expect-no-condition.R:15:1
    
    [ FAIL 0 | WARN 0 | SKIP 1 | PASS 18 ]
    
  3. t-kalinowski commented on Jan 7, 2025

    @t-kalinowski
    Member

    Just ran into this as well.

    library(testthat)
    test_that("expect_no_error", {
      expect_no_error(1+1)
    })
    #> ── Skip: expect_no_error ───────────────────────────────────────────────────────
    #> Reason: empty test
    
    test_that("expect_equal", {
      expect_equal(1+1, 2)
    })
    #> Test passed 😀

    Created on 2025-01-07 with reprex v2.1.1

  4. added a commit that references this issue on Jan 8, 2025
    7f7ec73
  5. hadley commented on Jan 8, 2025

    @hadley
    Member

    Should be fixed now (hopefully without breaking something different). I'll probably do a patch release in the next week or so.

  6. added a commit that references this issue on Jan 8, 2025
    a3cb74d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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