Testing a postcode input field sounds simple and yet, there are a few things that need to be understood in order to test it effectively. The simplest of tests are something like “Does the postcode have to have a space or not?” or “Will it accept both?”
We all have our ways of testing input fields, but I feel the postcode input field doesn’t always get the attention it deserves. Below are some examples of tests I think we should be adding to our test suite along with a list of unusual postcodes I have collected from other conversations on the subject as well as my own research.
- 6 or 7 characters. 8 with a space | A UK postcode is a max of 7 characters in length; 8 with a space.
- Can the postcode have a space?
- Can the postcode not have a space?
- Is the postcode in the right sequence?
- Can the postcode field accept the odd postcodes like SW1?
- Can the postcode be sent in lower case?
- Can the postcode be sent in upper case?
- Can the postcode be sent in upper and lower case?
- You could go to the extremities of checking all 124 postcode areas in the U.K., but personally, I think this is a bit of an overkill.
- What you might want to also consider are other parts of the UK such as Northern Ireland and the channel islands. Should these postcodes be accepted? If yes to Northern Ireland for example, then does that mean you shouldn’t accept Southern Ireland postcodes?
Unusual postcodes used for Postcode input field testing.
|W1J 7NT||149 Piccadilly, London. House of the Duke of Wellington|
|DE12 8HJ||17 Burton Road Coton in the Elms, Derbyshire. The Black Horse Pub, possibly the furthest pub from the sea in the UK.|
|SW1A 1AA||Buckingham Palace|
|HD7 5UZ||covers 7 streets; the most in the UK|
|CH5 3QW||the longest addresses in terms of numbers of elements|
|Anywhere in SA63||the Post Town is CLARBESTON ROAD (Example - SA63 4QJ)|
|W2 1JB||When all the premises get expanded you'll get the longest 'premise string' in the UK|
|PL7 1RF||Devon and Cornwall Police vs Devon and Cornwall Constabulary|
|GIR 0AA||special case Postcode for Girobank at Bootle|
|JE3 1EP||You will find that 'towns and large villages' are classed as Localities; Jersey; the Isle of Man and Guernsey are the Post Towns.|
|JE2 3XP||You will find that 'towns and large villages' are classed as Localities; Jersey; the Isle of Man and Guernsey are the Post Towns.|
|IM9 4EB||You will find that 'towns and large villages' are classed as Localities; Jersey; the Isle of Man and Guernsey are the Post Towns.|
|IM9 4AJ||has no street|
|GY1 3EW||There is the strange case of the PO Box with no other identifying info|
|PL7 1RF||Address list includes & ( -|
|IV27 4EG||29 LAIRG - 29 Lochside|