jeudi 5 mars 2020

How to write a test case to check whether a function is working correctly using testthat in r?

I have lots of functions to check whether each of them is working perfectly. I'm very new to using 'testthat' package. First my code has to read the data from a location

  baseData = fread(file = "./Data/ABC.csv", data.table = FALSE, stringsAsFactors = FALSE, showProgress = FALSE, encoding = "UTF-8")

Next I want to filter the data based on a particular column say ab_010 = 10. This is the code for that,

  baseData = baseData %>% filter(., ab_010 == 10)

Now I want to check whether the filtering has been done correctly using testthat. Also I have gone through many R bolgs such as this https://b-rodrigues.github.io/fput/unit-testing.html. But I didn't get a clear idea as how to apply this case to my scenario.Can anyone suggest me how to do that?

Aucun commentaire:

Enregistrer un commentaire