2. September 2009 05:41
When you are in a situation where you develop applications that are tightly integrated with other systems, you want to have multiple tests such as the unit test, the system test, the integration test and the user acceptance test. You want the unit test to only bring a class under test, without having to bother about other systems and/or applications. To enable this functionality you can make use of a mocking framework such as TypeMock.
Since unit tests are executed frequently on the build server, you need to somehow add this functionality to the build server. You can do this with two methods:
Install TypeMock on the Buildserver.
Add the following lines to your build script:
You now can use TypeMock. But what to do when you want to support multiple versions of TypeMock for different projects. Since when you update to a newer version to TypeMock you don't want to force all projects to update to the new version. To support this, you need to create a side by side installation. The following steps tell you how to achieve that.
Do not install typemock, but create a directory per version you want to support
Copy per version the files (see http://www.typemock.com/Docs/UserGuide/newGuide/Documentation/InstallingAutoDeploy.html for the list of files you have to copy) from the Isolator directory and from the x86 (or the x64, when running 64 bit) folder to the version directory (created in the previous step)
Add the following lines to your build script. Type will copy the dll's in the [version directory] to the GAC.
<Import Project="[version directory]\TypeMock.MSBUild.Tasks" />
<TypeMockRegister Company="TypeMock" License="TypemockLicense" AutoDeploy="True" />
You can now kick off your builds, and support multiple versions of TypeMock
There is a big caveat with this approach. TypeMock heavily uses the profiler to be able to mock the code. Only one version of TypeMock can have an instance of the profiler running, so when you are running builds in parallel which use different versions of TypeMock, your builds will fail. You can overcome this issue to not use the side-by-side installation, but make use of multiple build servers, with different TypeMock versions installed.
In TFS 2010, there will be a nice feature to support that scenario. You can add metadata to your build agent to indicate which version of TypeMock is installed. In the build definition you can add metadata to indicate which version of TypeMock is required. When you kick off your build, the build controller will automatically look for a server that satisfies your demands and the build is executed on the correct build server