rmendels / rerddapXtracto

xtractomactic using rerddap
Other
14 stars 4 forks source link

tests #3

Closed sckott closed 5 years ago

sckott commented 7 years ago

highly recommend implementing a test suite, following e.g,. http://r-pkgs.had.co.nz/tests.html

rmendels commented 7 years ago

Hi Scott:

I thought about this (the only way I knew how to get a package ready was following Hadley's web page and using his tools), but how to compare it with a known result was an issue and still do a test worth doing. Also, I am having a lot of trouble as it is with CRAN and xtractomatic because the examples and the vignettes take too long. So you end up with examples that aren't meaningful. Also where things usually break are the odd datasets that have different dimensioning. There are so many of them with so many varieties that I don't know how to test them all. One reason I went to "parsedate" is in some of these the data gets very fine. Lubridate requires me to know which format the date is in, parsedate does not. I was having a lot of problems until I stumbled on that package. Can I implement tests that CRAN doesn't run?

On Jan 4, 2017, at 9:55 AM, Scott Chamberlain notifications@github.com wrote:

highly recommend implementing a test suite, following e.g,. http://r-pkgs.had.co.nz/tests.html

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.


"The contents of this message do not reflect any position of the U.S. Government or NOAA."


Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center Note new street address 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

sckott commented 7 years ago

Can I implement tests that CRAN doesn't run?

yes, see testthat::skip_on_cran() just put that inside your test block and it will not run on CRAN - but will run locally and on Travis

sckott commented 7 years ago

You don't need to test all possible datasets, just test major functionality of especially the functions you export to the user. Just start simple (e.g., does rxtracto give back the class of object you expect it to give), and move on to more complex from there. A good strategy is probably to avoid testing dimensions of objects since those kinds of things can change.

I like it when test suites test failure behavior - that is, do your functions fail as you expect them to - the goal is to strive to fail gracefully letting the user know what happened