14 February 2013

Hosts file editor to switch an environment

In software development, the built code will be promoted to higher environments to test the quality. There could be different number of environment based on the requirements. However the commonly seen such environment across different projects are DEV, QA, STAGING and PRODUCTION.

We can hit the Web services or web application hosted on different environments by changing the host entries on the test machine. But changing the host entries is time consuming and error prone. Typically testers/QAs will be changing these host entries to change the environments around 2 to 3 times in a day. This task is boring. So to get rid of this mundane task, created small windows client application utility.

User interface:

Hosts file editor to change the environments


The Environment Changer Tool has prerequisites for keeping host entries in the hosts file for each environment:

  1. All host file entries for a given Environment has to be present under it. This anyway you would have already following it.For example if you have a DEV environment and have the below hoist entries, they all should like below in your host entries.

    111.222.333.444 webservices
    121.222.333.445 apiservices

    #112.222.333.444 webservices
    #122.222.333.444 apiservices

  2. The different environments will be configured in the application config file(app.config file). Each environment should be separated by semicolon(;).
  3. The hosts file will located more or less at "C:\WINDOWS\system32\drivers\etc". However if need, this settings can also be set in config.
  4. The Tool is windows form application built on .NET 2.0; So the .NET framework should be present on the machine.

Host file editor application config file:

<?xml version="1.0"?>
    <add key="Enviroments" value="LOCAL;TEST;UAT"/>
    <add key="HostFileFullName" value="C:\Windows\System32\drivers\etc\hosts"/>

That's it.The tool is really simple. Just keep your host entries as per the prerequisites and you will find the tool really helpful. By using this tool you can save around 2 minutes of time, whenever you want to change environment.

The tool now can be downloaded from codeplex