Skip to content

Commit

Permalink
feature: add mstest TestProperty Attributes to test, like Owner or an… (
Browse files Browse the repository at this point in the history
#63)

* feature: add mstest TestProperty Attributes to test, like Owner or any other custom TestProperty attribute

* feature: add Traits for any framework (mstest, xunit, nunit) to Test Attributes

Co-authored-by: Victor Grigoriev <[email protected]>
  • Loading branch information
Shakevg and VictorGrigoriev authored Apr 19, 2022
1 parent f0c1cca commit 110b746
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ReportPortal.VSTest.TestLogger/ReportPortalLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using System.Collections.Generic;
using ReportPortal.Client;
using System.Diagnostics;
using System.Linq;
using System.IO;
Expand Down Expand Up @@ -217,7 +216,8 @@ private void Events_TestResult(object sender, TestResultEventArgs e)
}

// find categories
var testCategories = e.Result.TestCase.Traits.Where(t => t.Name.ToLower() == "Category".ToLower()).Select(x => x.Value).ToList();
var testCategories = new List<string> ();
var traits = e.Result.TestCase.Traits.ToList();

if (e.Result.TestCase.ExecutorUri.ToString().ToLower().Contains("mstest"))
{
Expand Down Expand Up @@ -246,6 +246,13 @@ private void Events_TestResult(object sender, TestResultEventArgs e)
Type = TestItemType.Step
};

// add traits to Attributes
if (traits.Any() && startTestRequest.Attributes == null)
startTestRequest.Attributes = new List<ItemAttribute>();
foreach (var itemAttribute in traits.Select(x => new ItemAttribute
{ Key = x.Name, Value = x.Value }))
startTestRequest.Attributes.Add(itemAttribute);

var testReporter = suiteReporter.StartChildTestReporter(startTestRequest);

// add log messages
Expand Down

0 comments on commit 110b746

Please sign in to comment.