Similarly, it becomes much easier to verify if you decompose the redirect mechanism into several functions: a) a function that defines the destination URL, and b) a function that performs the redirect.
So you can easily test function A, and function A is the one you want to test anyway. This is the code for you . This is where your real logic is. FunctionB is not your code; this is ColdFusion gut, and there’s not much point in testing CFLocation.
If you are fulfilling a mission to achieve 100% test coverage, you can conduct 10 tests for a function where you execute all the different branches of your logic, and then one test for function B, which redirects in the way that Terry suggests; therefore this way you only get 1 slow test instead of 10.
You can generalize this approach for use in other scenarios: file systems, web services, http, ftp, email, etc .: "Extract material that you can control and want to test material that you cannot control, and you don’t want to check "
source share