nestanyol / CoolBeans

Multi-metabolite signatures from exposure features
Other
1 stars 0 forks source link

Setup unit testing and show how one unit test works #37

Open lwjohnst86 opened 11 months ago

lwjohnst86 commented 11 months ago

Unit testing is a core component to building R packages (and software in general). The R Packages book goes into more detail here: https://r-pkgs.org/testing-basics.html

I set this up with usethis::use_testthat() and then I added a unit test file for one script by opening that file (preprocessing.R) and running usethis::use_test(). Each unit test you write should test one thing, in this case, I am testing that the preprocessing zero-centers the data. With testing, you always use the "actual" values, and compare with what you expect it should be. In general, for every "user facing function", you should write as many unit tests as you can to confirm that it gives the output that you expect the function to output. This part of coding is also one of the harder ones.

lwjohnst86 commented 10 months ago

@nestanyol You have a chance to look at this?