Posts tagged ‘webserver’

UnitTesting a door

I was explaining to somebody from non development world some time back what unittesting is about. At the time the best thing I could come up with was something along the way. Well if your building a house and then you install a door. Now you have to make sure the door works. In case of the door we write Unittest that makes sure that the door nob turns and does actually open the door. We also make sure that the door latches when it’s shut, further we make sure that the door fully opens and closes without any trouble. We make sure the key fits and can lock and unlock the door. Since we are at it we might as well shake the door and make sure nothing is rattling, that all screws were tightened up properly. Further if the door gets replaced it has to be verified that it works as well and the same key can be used as before.

The good part is once you have written the unittest it will work for the replacement door as well. This is where you get the most bang for you buck. Unless you never rewrite your software, that’s another story then. So let’s say your interior designer came up with a new door, a sliding door. Now your tests fail of course and they should, the function of the door has changed and it’s time to update the unittest. The base will stay the same the same key might still fit, the door should shut properly, etc. One of the new functions might be that the door slides open when a person walks into the sensor that triggers the door etc.

So how does it look when you need to unittest objects in your new webserver project. It’s similar but it’s a little different the problem is when you are running on a webserver you are running in a container. The container is the webserver. So logically you can’t test the door as the door can only be accessed when inside the container ( installed in the house ). The problem with that is that you do not want to unittest against a live webserver. As you can not get down to the object level to address the door directly. Therefor the trick is to setup a unittest environment that can fake the container / house. Once you do that your door thinks that it’s installed in a house and you can verify that the door functions as expected.

There is only one thing left to say, Jawoll Mein Agile F├╝hrer