Junilu Lacar wrote:Ok, I still have a few minutes to get this reply in. Consider these three tests:
If you read though these test carefully and understand their intent, there's actually a theme and progression here. The code does not make that apparent though. Some of it can be fixed by renaming the methods so that a pattern and relationship between them can easily be discerned. Another thing you can do is to factor out some of the repetitive setup details and make the intent more clear.
As for clarifying the test names, you could rename them like this:
Gotta go now. I'll add to this later.
Junilu Lacar wrote:I don't get the difference between these two tests:
public void getBioSamplesSameBioProjectForBcids()
public void getBioSamplesDifferentBioProjectForBcids()
When I compare the bodies of these two tests, the only difference I can pick out is that the first is adding getBioSample2ExperimentPackage() while the second one is adding getBioSample3ExperimentPackage() to the repository. Yet, I don't see anything in the code that explicitly tells me how Sample 2 and Sample 3 are different and how Sample 2 is related to the "SameBioProject" part of its test name and how Sample 3 is related to the "DifferentBioProject" of its test name.
That test code is not helping me connect the dots; instead it makes me wonder what I'm missing.
Junilu Lacar wrote:EDIT: on second thought, if you renamed the test to getBioSamples_returns_empty_list_when_given_empty_bcids_list, then that's probably going to attach enough meaning to the new ArrayList<>() parameter.
I have to infer from the assignment on line 15 and the assertion on line 16 that the new ArrayList is supposed to set up the an empty repository of BioExample BioSample objects.
Junilu Lacar wrote:I'd have to examine some code to say for sure but it might. In these cases, it's usually a good idea to factor that knowledge out to something that falls under what Peter Coad calls a Moment-Interval Archetype in his writings about Modeling in Color.