Best practice to test a web application, regarding domain name and integration with external service (like Amazon S3)
I have run into these problems several times and was never able to find a comfortable solution. Let's say my website has the domain name MyDomain.com. When I run the tests on the test machine (a continuous integration server), I will modify the HOSTS file on this machine so the MyDomain.com is mapped to this local machine instead of the real production server. This doesn't work very well for many situations. For example, my application will create subdomain names user1.MyDomain.com dynamically but this is开发者_运维技巧 difficult to keep the testing flexible.
Another problem is my web application will interact with Amazon S3, and sometimes other service like Amazon Simple Message Queue. I am only comfortable to include these interaction in my tests but I am never happy with my solution for mixing testing and production on Amazon services.
Could somebody offer some tips on these issues? I would like to make my testing framework clean and flexible. I am sure this is a common question for all web applications and there must be a mature way to deal with these.
Thanks!
I use different host names when in test or dev modes. Including different s3 buckets and s3 host names. That enables testing and development of all app features including s3.
I think it is easier to change the host names being used rather than messing with the hosts file.
精彩评论