Showing posts with label Attributes. Show all posts
Showing posts with label Attributes. Show all posts

Sunday, April 26, 2009

MSTest and TeamCity trouble

When I run test from Visual Studio all tests pass but when I setup test environment from Teamcity half of my test fails.

Problem was because some of assemblies was missing in mstest environment. Actually, I have used Enterprise library and I had custom trace listener. Test project had that trace listener in references. But when Teamcity runs mstest my assembly was missing in build agent working folder.

All assemblies that are not used directly in test (for example class from my assembly was dynamically loaded by enterprise library application logging block) will not be copied to test folder. Therefor, those test methods should be decorated with attribute like:


[DeploymentItem("MyTraceListener.dll")]


Somehow, this was not necessary when you run tests from Visuals Studio IDE.

I hope that I save you some time.

Thursday, December 18, 2008

Visual studio test environment and provide additional files

If you want, for example, to copy additional files to test location for some unit test, for example, some XML file, do the following:
  1. Add test.xml to test project
  2. Set "Copy to output directory" property of file to "Copy always"
  3. For test method add [DeploymentItem("test.xml")] attribute.

Friday, November 28, 2008

Customize debug view

I made a wrapper class for some other class. And every time when I wanted to see in debugger what does it wraps I had to view the class members and theirs members just to view that name of the wrapped class is something.

In order automatically to view important members of class and help you to fast identify object put this attribute to class:


[DebuggerDisplay("Name = {name}")]


...where "name" is class property or field name.