Freigeben über


Creating a bug on test failure ….

Note: Cross posted from Nothing geeky....

Permalink

  1. One of the common requirement while running E2E build is to log a bug automatically when the test run fails. It is very simple to achieve this functionality by customizing the workflow.

  2. Lets go through the steps for the same :

  3. 1.Make a copy of "labdefaulttemplate.xaml " and check-in the new xaml.

This post talks about getting started with E2E customization. Follow this post to make a copy of labdefaulttemplate.xaml and check-in the new XAML to source control. Let's call it "CustomizedE2E".

2.Now open the xaml in the workflow editor. Locate the "If all tests have not passed" block in the workflow.

3.Add a sequence activity inside the if block and put the "Set build status" activity inside the sequence. Drag and drop the "OpenWorkItem" activity from "Team Foundation Build activities" section in the toolbox into this sequence.

clip_image001

4.Specify values to the parameters of the "OpenWorkItem" activity.

clip_image002

Below are the values that I have specified for each parameter :

Parameter

Value specified

Description

AssignedTo

BuildDetail.RequestedFor

The value of this parameter will be set to the "AssignedTo" field in the bug.

"BuildDetail.Requested" will refer to person who has queued the build.

Comment

"Bug"

The string specified here will go in to the description part of the bug.

CustomFields

New Dictionary(Of String, String) From {{"System.Reason", "Build Failure"}, {"Microsoft.VSTS.TCM.ReproSteps", "Run tests under BVT suite"}, {"Priority", "1"}, {"Severity", "1 - Critical"}}

This is a dictionary which holds the values of various fields in the bug like priority, severity,repro steps....

Title

String.Format("Test run {0} queued as part of build {1} has failed ",TestResults.TestRunId.ToString(), BuildDetail.BuildNumber)

This is the title of the bug. I have added the test run ID and the build number in the title.

Type

"Bug"

This is the workItem type

5.Save the xaml and check it in to the source control. Create a new E2E build definition based on this template.

6.Now run the E2E build and you can notice a bug being logged on test failure.

E2E build summary pointing to the newly logged bug ..

clip_image003

The bug that was logged automatically by the E2E workflow..

clip_image004

Hope that helps ! Cheers :)

Comments

  • Anonymous
    June 18, 2014
    Thanks for the Article. I have to add test case in "Test Cases" column, How to do that one? Please help me Thanks, Kamal

  • Anonymous
    October 08, 2015
    I am doing something similar to what Kamal is doing. I would like to add more information about the tests that failed to the Details section. Any ideas on how to achieve that?