Do you have tests for difficult to spot errors (e.g. arithmetic, rounding, regular expressions)?
Updated by Brady Stroud [SSW] 1 year ago. See history
Sample Code:

Figure: Function to calculate a total for a list of items
For a function like this, it might be simple to spot errors when there are one or two items. But if you were to calculate the total for 50 items, then the task of spotting an error isn't so easy. This is why a unit test should be written so that you know when the function doesn't work correctly.
Sample Test: (Note: it doesn't need a failure case because it isn't a regular expression.)

Figure: Test calculates the total by checking something we know the result of.
Categories
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.