dev
dev copied to clipboard
Write unit tests
some units tests include:
- known number of unique language codes
- range of segment counts (11-161)
- NAs in various columns, including the feature columns, language codes, etc. (i guess any column that can't contain a null)
- duplicate feature vectors (note already in aggregation script)
- missing feature vectors (also already in aggregation script)
- column type checks (we might want to cast certain columns to numeric, character, etc.)
- segment ordering conventions and that all segments are valid according to these
http://kbroman.org/pkg_primer/pages/tests.html
for unit tests. it'd be nice to integrate travis as well:
https://travis-ci.org/
@drammock do you have a preferred testing framework for R? i see a few different options, like
https://github.com/yihui/testit https://github.com/hadley/testthat
a quick-and-dirty approach would be to write tests that run on the output of the aggregation script (language code checks, segment convention validation, that all bibtex keys match InventoryIDs, etc.)
a more in-depth approach would be to integrate the tests into a phoible R package. i guess the question for me is whether we move forward with an R package by writing the tests, thus skipping the quick-and-dirty in part (tests of course still need to be written :)
what do you think?
I haven't done proper test-driven development in R before, only ad-hoc testing scripts. I like the simplicity of testit
(the README was enough that I already know how to use it, whereas testthat
says "go read this whole chapter (and probably, all the chapters that came before it)." Honestly I've been burying my head in the sand about writing tests because I secretly want to switch to python (for which I use nosetests
). Might be time for a skype meeting so you can talk me down from triggering another overhaul :grimacing:
We could also ideally include continuous integration
Note some tests I've written here should be eventually incorporated into dev:
https://github.com/bambooforest/phoible-scripts/blob/master/tests/tests.md
@bambooforest -- create the list of tests that we need (as per our discussion June 2, 2020)
tests failing here:
- inventory 2478 is the one failing the phoneme uniqueness test.
- invalid ISOs: "daf" "duj" "wit" "kxl" "krm" "kxu" NA "drh" "dit" "mwd" "qgu" "bjd" "ggr" "yiy"
- invalid glottocodes: NA is the only one
- inventory 695 has one row where the language name is "dida" instead of "Dida" (capitalization)...