What is the syntax to use the [TestDescriptionAttribute][1] of a test to populate the Description column in the Test Results window?
Context: Visual Studio 2008 Team System
I’ve read the documentation, but am not able to find a concrete example.
Based, loosely, on Ngu’s suggestion, I’ve tried:
using GlobalSim;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.WebTesting;
namespace GlobalSimTests {
/// <summary>
///This is a test class for PongerTest and is intended
///to contain all PongerTest Unit Tests
///</summary>
[TestClass()]
[TestDescriptionAttribute( "hello" )]
public class PongerTest {
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext {
get {
return testContextInstance;
}
set {
testContextInstance = value;
}
}
/// <summary>
///A test for Ping
///</summary>
[TestMethod()]
public void PingTest () {
Ponger target = new Ponger();
string expected = "Pong";
string actual;
actual = target.Ping();
Assert.AreEqual( expected, actual );
}
}
}
This compiles, but doesn’t display the test description in the Description column of the Test Results window.

I’ve also tried this syntax:
/// <summary>
///A test for Ping
///</summary>
[TestMethod()]
[TestDescription( "hello" )]
public void PingTest () {
Ponger target = new Ponger();
string expected = "Pong";
string actual;
actual = target.Ping();
Assert.AreEqual( expected, actual );
}
Which returns from the compiler:
Attribute ‘TestDescription’ is not valid on this declaration type. It is only valid on ‘class’ declarations.
Here is the syntax that works. Thanks all!
/// <summary>
///A test for Ping
///</summary>
[TestMethod()]
[Description( "Hello" )]
public void PingTest () {
Ponger target = new Ponger();
string expected = "Pong";
string actual;
actual = target.Ping();
Assert.AreEqual( expected, actual );
}
As @Ngu has said, put it on the top of a test method
EDIT: TestDescriptionAttribute is from
WebTestingnamespace, which should not be applied for unit testing. Use the DescriptionAttribute instead, which is part of theUnitTestingnamespace.See the modified code above & I am sure, it will work.
EDIT2: To find something like that, look at the classes in the same namespace. That is how classes are arranged, so that one can find it easily.