carpentries-incubator / lesson-R-packaging

R Packaging
https://carpentries-incubator.github.io/lesson-R-packaging/
Other
5 stars 10 forks source link

Uneven number of elements test #45

Closed liekelotte closed 2 years ago

liekelotte commented 2 years ago

I am a little confused about this part of the testing exercise. People are supposed to write a test that passes an uneven number of elements. This is the same as running the function with an uneven number of elements and the function throwing an error. There are no assertions in the test, making it a different kind of test than you have run so far.

I predict that when people do this exercise, they will take the length of the names and assert that there is no remainder when dividing it by 2. That's what I would do if I got this exercise.

Should this be changed or clarified somehow?

liekelotte commented 2 years ago

In addition, I'm wondering how you ran the test after you made the test for uneven elements. Should the first test not fail as well? The one that checks rows and columns?

PabRod commented 2 years ago

TL;DR: the suggestions here have been implemented in the commit below.

The purpose of this subsection is to provide a mini-example of a development loop. It is perhaps the deepest topic we'll mention in the course, and it will massively benefit from the spoken explanations of the instructors.

If you found the exercise confusing, then it is. We can easily reformulate it.

Although I agree it can be a bit strange, I don't see the lack of an assertion in our test as a big problem. Very often developers create assertion-less tests when they suspect a crash may happen. Anyways, this is easy to solve by adding an assertion with, say, the naive assumption that 3 groups will be formed.

Regarding the second question, no, only the test with an uneven number of elements should fail.