How To Change Test Scribe Template
I’ve wrote about Test Scribe couple of months ago and explained how you can Generate word documents from Microsoft Test Manager.
Test Scribe is an awesome tool for Generating Test Documents, but can I change the document template? Test Scribe comes with a Default Template and many customers what’s to change the template to their needs.
This is the best way I found how to do that, and it require to drill down to some file inside the Test Scribe.
Make Sure you backup all files before doing any changes!!
Locate Test Scribe Template
Navigate to –>
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\TeamTest
Copy “Microsoft.TeamFoundation.TestManagement.Tools.TestScribe.sx” to another folder, change the file name and extension to “Microsoft.TeamFoundation.TestManagement.Tools.TestScribe.zip”.
Extract file content, and you should have TestPlan and TestRunSummary folder contains the Document Template.

Test Plan Directory Content:

Changing Test Plan Section
I’ve open “TestPlan” directory and start editing the “TestPlanSection.tt”.
In the picture below you can see the two selected Paragraphs that are responsible to the static text display in the header of the document.

I’ve remove those and also changed the Header style, instead of showing the Test Plan Id I wanted to only show the Test Plan Name and make sure the Name is hyper link to the Test Plan it self.
SprParagraph
(
"Heading1",
SprImage("/Images/TestPlan_32.png"),
SprText(SprHost.Resources.GetString("TestPlanLabel")),
SprText(String.Format(CultureInfo.CurrentCulture,
SprHost.Resources.GetString("ItemHeaderFmtString"),
"")),
SprHyperlink(TestPlan.Name, BuildUrl("testing/testplan/open?id="
+ TestPlan.Id.ToString()))
);

Adding Attachments
This is another issue I keep hearing from many customers, How can I add attachments to the document?
In the TestCaseSection.tt just before the “SprMultilineText("Errormessage", testCase.Description);”
Add the following:
if (testCase.Attachments.Count > 0)
{
SprParagraph
(
"Heading4",
SprText("Attachments"),
SprText(String.Format(CultureInfo.CurrentCulture,
SprHost.Resources.GetString("ItemHeaderFmtString"),
testCase.Attachments.Count))
);
for (int i = 0; i < testCase.Attachments.Count; i++)
{
ITestAttachment attachement = testCase.Attachments[i];
SprParagraph
(
"Heading5",
SprText(String.Format(CultureInfo.CurrentCulture, "{0}: ", i + 1)),
SprHyperlink(attachement.Name, attachement.Uri.AbsoluteUri)
);
}
}

Download Custom Template (Backup and Copy to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\TeamTest)
This is for now, I’ll continue customizing the template over the next weeks.
Enjoy