r-lib / testthat

An R 📦 to make testing 😀
https://testthat.r-lib.org
Other
868 stars 313 forks source link

expect_equal does not print values of vectors when sizes differ #1931

Closed levsa closed 2 months ago

levsa commented 4 months ago

It would be nice if expect_equal printed the values even when sizes differ. Example:

> a <- c(1)
> b <- c(2,3)
> testthat::expect_equal(a,b)
Error: `a` not equal to `b`.
Lengths differ: 1 is not 2
hadley commented 2 months ago

You should switch to the 3rd edition where this looks much better 😄

a <- c(1)
b <- c(2,3)

testthat::local_edition(3)
testthat::expect_equal(a,b)
#> Error: `a` (`actual`) not equal to `b` (`expected`).
#> 
#>   `actual`: 1  
#> `expected`: 2 3

Created on 2024-04-17 with reprex v2.1.0

More info about the 3rd ed at https://testthat.r-lib.org/articles/third-edition.html