I stumbled across an interesting problem today whilst trying to enable unit testing as part of a TeamBuild on our Team Foundation Server.
One of our projects has an extensive test harness created using the unit testing features of Visual Studio 2005. This test harness exercises the business objects in the application, which in turn call in to the underlying database. The test harness tests the behaviours of the business objects and verifies that the correct changes have been made in the underlying database by executing direct queries against it. The tests run from a known good state of the database, which is achieved by dropping the relevant database, recreating it and populating it with known data before each test run.
Our test harness has been working perfectly on developer workstations for some time but we recently decided to make it part of the automated nightly build of the application that occurs on our Team Foundation Build Server. So today I enabled testing in the Team Build configuration file and set it to use the specific test lists we have configured for this set of tests. When I manually ran the Team Build it showed that the tests had failed and that there were no test results but the build log file showed that all test had passed. Logging on to the build server showed that there were the .TRX test result trace files present in the build directory but these were not being copied to the build drop directory, hence Team Explorer thought that no test results had been returned.
After quite a bit of poking around I finally figured out what was going on. The database files for the test database created at the start of each test run were being created by the test harness in the current directory; during Team Build testing the current directory resolves to the Test Results directory below the build directory. At the end of testing, Team Foundation Build attempts to copy the test results from this directory to the build drop directory and appears to do so by trying to copy all files from the Test Results directory. If, for some reason, it cannot copy a file the entire copy process fails. In our case, the database and database log files were stored in this directory and Team Foundation Build was trying to copy these to the build drop directory along with the test results, but could not do so because the files were locked by Sql Server. As these were the first files it tried copying, none of the actual test results got copied to the build drop location and a test failure was reported because the test result files could not be copied, not because any of the tests had failed.
I resolved the problem by modifying the test harness so that it creates the database and log files in a temporary directory on the server, not the current directory. Team Foundation Build can then copy all test results files to drop directory and Team Explorer now acknowledges the presence of test results. Moral of this story.... don't rely on using the current directory when running automated tests on the server. They may work fine on a developer workstation but that doesn't mean it will work as desired on the build server.
------
David
del.ico.us |
Digg It |
Technorati |
StumbleUpon |
Furl |
reddit
I stumbled across this podcast from Ron Jacob's ARCast series on Channel 9 today. It's a great discussion on the role of patterns, or more precisely anti-patterns, in building service-oriented enterprise solutions. If you're new to the implementation of service orientation there's some great material in here to make you think and help you short-circuit some of the learning process. If you want more details on some of the stuff discussed in this podcast, take a look at
Just get it downloaded on to your iPod and plug yourself in!
------
David
ARCast - Patterns and Anti-Patterns for SOA Applied
In August 2004 I wrote a presentation called Patterns for SOA that would change my life – really! Since that time I have delivered this talk about 15 times in various locations from San Francisco to Amsterdam to Bangkok and many others. In spite of this I never really knew if this presentation was really helping anyone in getting real systems built until today when I met Denny Boynton who told me how he had taken Patterns for SOA back to his company and began using these principles to help change the way they built services. Sound interesting? Well I thought you might enjoy hearing more about these patterns, anti-patterns and the ways they have been applied.
Listen to the podcast(WMA)Listen to the podcast(MP3)
del.ico.us |
Digg It |
Technorati |
StumbleUpon |
Furl |
reddit