What is the general goal of the feature?
One thing I tend to come across when working on ODK Collect forms is that comprehensive testing becomes very difficult. It's also time-consuming, particularly when all answers are required and there are a lot of dependencies and skip logic - we have to go through the form filling out all of the previous items again in order to get to the piece we're interested in. Similarly, when items are changed slightly or the form is restructured (adding or changing the scope of relevant fields, groups and repeats in particular) it can have unanticipated knock-on effects.
It seems to me that this would be a case for unit testing. It would be great to see some version of unit testing incorporated for ODK Collect forms.
What are some example use cases for this feature?
I'd envision for example a case where the skip logic/visibility for a particular question p
depends on the input to a previous question q
where the answers can be 1-10. Say I change how q
works - I expand the constraint so that now 0 is allowed, but I haven't remembered that p
, way down at the end the form, doesn't make sense now if ${q}=0
. I'm envisioning a scenario where I can specify unit tests that show what would happen in each case, which questions would be displayed and what the results would be. Then when I add my new expanded q
, I can just modify an existing set of tests with q
set to 0, and get a report to see which questions/groups are displayed and what the results are. I don't have to do a full manual re-test of the form following all the branches of concern to their various ends.
In a slightly different version, say I already allow 0 as an answer to q
(say this is the number of eligible respondents in the house), but I have the rest of the questions are in repeat called rGroup
, set to repeat ${q}
number of times - so each eligible person will do the full survey. Having ${q}=0
here just means that the survey finishes immediately with not further questions asked. Then say I change my whole structure so that I now select one person randomly from eligible respondents. Now I only have a few questions in that rGroup
for everyone (getting their names for example), but the rest of the questions have been moved outside the repeat so they only appear once, for the selected person - however they still shouldn't appear if there is no one eligible in the household. I should add a relevant
around the non-repeated questions to keep them from appearing if ${q}=0
, but say I forget - if I had a previous test from first version with the result of q
set to 0, it would show me that all of my non-repeated questions are now showing where they wouldn't have before. (It would presumably come up with a lot of other changes too since the structure's been changed so much!)
What can you contribute to making this feature a reality?
I don't know if there is already a way to do this using existing unit testing tools? It would be great though to have the ability to do it with the same ease as writing an XLSForm.
I probably wouldn't be able to help build the feature unfortunately as I lack the coding skills, but I'd be excited to help test it.