qualR icon indicating copy to clipboard operation
qualR copied to clipboard

test: some suggestions for making failing test file more readable

Open maelle opened this issue 1 year ago • 5 comments
trafficstars

:wave: @quishqa!

I don't know yet why the Windows build is failing (I am on Ubuntu and can't run the tests locally yet see #9) however I think this test file can be made more informative when it fails by using more specific expectations. Some of them might be new to you, I think going over https://testthat.r-lib.org/reference/index.html once in a while is useful as new expectations appear over time (it's useful for me at least!).

Anyway as a summary:

  • no need to explicitly load the internal data.
  • I had trouble understanding the failure param_means["ws"] > 1 (actual) not equal to param_means["ws"] < 2 (expected)., using expect_lt() and expect_gt() instead will give a clearer failure.
  • I'd recommend moving the expectations around the class of pinheiros and its columns before the calculations.
  • These expectations around classes should use https://testthat.r-lib.org/reference/inheritance-expectations.html although for the columns I have added a comment, I think it'd make sense to create the vector of all class names then use expect_setequal() https://testthat.r-lib.org/reference/expect_setequal.html (it does not check the order of columns).

maelle avatar Sep 30 '24 04:09 maelle