Use for WorkItemAttribute?

I noticed there the Microsoft.VisualStudio.TestTools.UnitTesting.WorkItemAttribute attribute, available in Visual Studio testing (I use VS 2010 Premium and work items with TFS 2010.)

Labeling a test method with a work item number sounds convenient, but does it really do something? I canโ€™t say if there is any tool support for it at all. I installed it like this:

[WorkItem(25788)] [TestMethod] public void TestSomethingSpecificToABug() { ... 

But not magic - I thought, maybe the context menu in the test in the test results window may offer to open a work item, or Team Explorer may have a function to search for tests. MSDN documentation doesn't help either. Why is this attribute useful?

+6
source share
6 answers

According to " Testing Software with Visual Studioยฎ 2010" Jeff Levinson (Addison-Wesley Professional, February 2011, ISBN-10: 0-321-73448-3):

It also means that one existing property should no longer be used: Linked work items. This value is not reported to the data and therefore cannot be used for reporting. If you are currently using this property, consider associating your test with the actual test Work Unit Type Case.

So the answer is: do not use this with TFS 2010.

+3
source

The TestItem Test Method attribute is not used to match test methods to verify cases. It is usually used to associate a test method with an error. Related C # example from Code Index - How to detect ignored tests :

When using MSTest to create a unit test suite, you can use the [Ignore] attribute to tell the MSTest engine not to run the test instead of commenting on it. You can also use the [WorkItem (id)] attribute to link the unit test to an error database (such as TFS) so you can track why a particular test was flagged as ignored:

  [Ignore] [WorkItem(12345)] // bug 12345 describes why this test was ignored [TestMethod] public void IgnoredButWithWorkItemTest() { //The actual code is not important; } 
+3
source

It will bind the unit test to the work item in TFS. I would provide a link to additional information, but it seems to be poorly documented.

I have not used it myself, but I believe that it can be used to create reports on the status of work items.

+1
source

This is no longer needed: in VS 2013 via CodeLens

Find related work items (Alt + 7)

enter image description here

Find scanned codes (Alt + 8)

enter image description here

Find related errors (Alt + 9)

enter image description here

To view the test definition, double-click the test.

enter image description here

ABOUT! for those who cherish Lync:

Contact the owner of the object (Shift + F10)

enter image description here

+1
source

I really remember that I used this attribute before, and the test results were attached to the corresponding WorkItem.

However, with Visual Studio 2012, it no longer works, or I forgot which mechanism was really responsible for the magic. Maybe this only works through the build server?

0
source

Pulling attributes from test binary is really useful when you have a home test harness built in to test Selenium UI modules.

After the test fails, I can pull out the WorkItemAttribute value using System.Reflection.MemberInfo.CustomAttributes, and then find the identifier using the TFS API. If the work item is an error and it is still active, I can automatically resolve the error for this error. Thus, I can run a failed test every day and automatically eliminate the rejection of randomization.

0
source

Source: https://habr.com/ru/post/897011/


All Articles