Loading...

Test: Generate 10 addresses each from US, UK, Germany, Japan, Canada

Expected: Each address is validated using the correct country's rules

Result: If UK addresses fail US validation, your country detection works.

If UK addresses pass US validation, your routing may be wrong.


Strategy 3: Boundary Value Testing


Generate addresses at the extremes of valid ranges:


  • Postal codes at the minimum and maximum values for each country
  • Street numbers from 1 to 99999
  • Street names with 1 character and 50+ characters
  • City names with hyphens, spaces, and apostrophes

  • Strategy 4: Mutation Testing


    Take valid generated addresses and introduce specific mutations:


  • Remove the postal code - Should trigger a required field error
  • Swap city and state - Should fail city-state validation
  • Use wrong postal code format - A US ZIP in a UK address field
  • Add invalid characters - Emojis, HTML tags, SQL injection attempts

  • Strategy 5: API Stress Testing


    If you use a third-party validation API (SmartyStreets, Google, Melissa, Loqate):


  • Generate 1000 addresses in batch
  • Submit them all to the API in rapid succession
  • Measure response times, rate limiting, and error handling
  • Verify your application handles API failures gracefully

  • What to Validate


    Format Validation


    Check that each field matches the expected pattern:


  • US ZIP: 5 digits or 5+4 digits
  • UK Postcode: Alphanumeric in correct pattern
  • Canadian Postal Code: Letter-digit-letter digit-letter-digit
  • Phone numbers: Correct number of digits for the country

  • Consistency Validation


    Check that fields are internally consistent:


  • City matches postal code - "New York" with ZIP "90001" (Los Angeles) should flag
  • State matches postal code range - California should have ZIPs starting with 9
  • Country matches postal code format - A 5-digit code should not match a UK-format address

  • Completeness Validation


    Check that all required fields are present:


  • Street address is not empty
  • City/locality is provided
  • Postal code is provided (for countries that use them)
  • Country is specified (for international forms)

  • Measuring Validation Quality


    Track these metrics during testing:


  • True positive rate - Percentage of valid addresses correctly accepted
  • True negative rate - Percentage of invalid addresses correctly rejected
  • False positive rate - Invalid addresses incorrectly accepted (high risk)
  • False negative rate - Valid addresses incorrectly rejected (user frustration)

  • Aim for a false negative rate below 1% — rejecting valid customer addresses directly hurts conversions.


    Tips


  • **Test validation with and without auto-formatting** - Some validators auto-correct; test the raw logic separately
  • **Include addresses from every country your validator claims to support**
  • **Run validation tests on every code change** - Regression testing catches introduced bugs
  • **Log validation failures with full context** for debugging
  • Related Articles

    What Is a Fake Address Generator and How to Use OneUS Address Format Guide: How to Write American AddressesAddress Formats Around the World: A Developer Guide