When writing unit tests, it is normally advisable to test the edge cases.
However, are these the right sort of things?
Thanks
Edge CasesThe situation where the test examines either the beginning or the end of a range, but not the middle, is called an edge case. In a simple, one-dimensional problem, the two edge cases should always be tested along with at least one internal point.
An edge case is a problem or situation that occurs only at an extreme (maximum or minimum) operating parameter. For example, a stereo speaker might noticeably distort audio when played at maximum volume, even in the absence of any other extreme setting or condition. An edge case can be expected or unexpected.
Start by thinking about ways the code could fail and why. Make sure you understand the programming language and algorithms used. What are their weaknesses? Think on the extremes, think on different scales, different media, different use cases, think outside the box!
In software development, an edge case is a type of software bug that won't be a widespread issue. Instead, it only affects a small number of users, and devices, or can only be reproduced under uncommon circumstances. That doesn't necessarily mean that the bug is difficult to reproduce.
Your tests seem OK, but the phrase "edge case" normally refers to the tests and checks you need to do around the limits of the input.
Say you have a column in your database that can accept 50 characters. Your edge case tests are:
You can see that you are testing around and at the edges of your application where there are most likely to be errors. In this case there could be some confusion of the number of usable characters you can store which could cause errors in applications writing to your database.
Other tests where you would test saving a string of 20 characters and saving a string of 100 characters (say) should be done but these are going to be more stable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With