Search code examples
unit-testingurltestcase

Bad url test cases


I'm working on a function to validate http urls. I need some good and bad urls to do unit testing. Please share me your test cases.

Thanks.


Solution

  • There are many permutations and combinations ... also how strictly you are conforming to the standard spec is something to worry about

    What are the protocols supported ... is it only http ... or https, rmtp etc as well

    Consider things like domains and subdomains ... www.google.com and www.maps.google.com are valid

    Presence or absence of trailing slash

    Non-standard port ... http://www.example.com:8800

    Deep path after the host ... http://www.example.com/a/b/c/d/e/f/g/h/i.html

    URL Parameters ... http://www.test.com?pageid=123&testid=1524

    URL encoding ... and how are URL are encoded within a URL if they are the part of the parameters

    Anchor tags ... http://www.test.com/do.html#A

    Presence of special characters ... if any

    handling white spaces

    Max and Min size of a URL

    Interesting!!

    Have you investigated in existing libraries which let you validate the URLs