When we unit test we often need to change some Sitecore configuration for the tests. For example, we may have the following:
<sitecore> <configuration> <someNode name="myService">http://myservice:1234/endpoint</someNode> <settings> <setting name="mySftp" value="sftp://mysftp:21/" /> </settings> </configuration> </sitecore>
and we may need to change it to the following when running our unit tests:
<sitecore> <configuration> <someNode name="myservice">http://test.myservice:1234/endpoint</someNode> <settings> <setting name="mySftp" value="sftp://test.mysftp:21/" /> </settings> </configuration> </sitecore>
I had previously been handling these changes by using different build configurations with config transforms. The problem with this is that I prefer to run my unit tests across both DEBUG and RELEASE mode, since the optimizations when building in RELEASE mode (shouldn't but) can cause errors in some code. I could work around this by customizing my targets and making two build configurations for unit tests,
unitrelease, but this seems kind of hacky and I'm sure there are better solutions out there.
I'm wondering what techniques other people are using for handling these changes when running unit tests.
Note: Partial answers are totally acceptable for this one. I expect that there may be different techniques for different kinds of settings. Getting a bunch of ideas together that I and others can pick and choose from will make a great reference for the community! Of course, I will accept the answer that works best in the most cases :)