The reason is because the value generation is functionality of the code I am testing, it isn't a test fixture.
So, if the code I am testing generates a different number of values than I am expecting, the test needs to fail.
Yes, I may have made my initial example too minimal.
I am testing code that, given a set of data, generates a report.
The code that generates the report is part of the module I am testing, not a test fixture.
So, first, if generating the report throws an error, I want the test to fail and stop.
Next, the report has various properties, some properties are single values, some are arrays of values, and there may be one or more computed properties.
Currently I check that the non-array properties (stored and computed) equal their expected results.
This is also where I ensure the count of each array of values that was generated matches the expected count.
Then I iterate through each of the arrays of generated values in a for loop checking that each value matches its expected value. Each array is handled in its own loop.
So, if the report has two properties that are arrays of values, there are two loops, one per property.
Handling these separately, as opposed to comparing the entire report to an expected report value, has given me fairly good granularity in easily seeing which values in the report failed.
In Swift Testing, I can continue to do what I have been doing in XCTest, it works fine.
But, with the emphasis put on using arguments and parameterized testing instead of looping through values in the test itself, it made me wonder if there is any way to take advantage of its benefits for this use case. (Especially interesting was being able to run the test on only a single iteration of the loop)
And of course, I am asking these questions literally on day one of me using Swift Testing after watching two WWDC videos about it (which I thought were excellent, btw). So my understanding of Swift Testing is not very deep.
@smontgomery I really appreciate you gathering feedback and all the work done on Swift Testing. So far it has been frictionless to begin migrating XCTests and at first look it seems like it manages to be both very approachable and straightforward, with a small number of building blocks, but still very flexible and powerful.