[C]ORRECT: [C]onformance

Many data elements must conform to a specific format. For example, an email address generally follows the form:


(Where somedomain might be pragprog.com.) The name and domain portions of the address each follow a different set of fairly detailed rules. You can find many of them laid out at Wikipedia.[28] Imagine that you want to validate the conformance of an email address to the many rules. (You really don’t want to, however. This is a case where you’re much better off leaning on the efforts of others. See the complete spec.[29])

Perhaps your code parses an email address, attempting to extract its name portion—the part leading up to the @ sign. But you want to worry about what to do if there is no @

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.