Skip to content

Commit 21c8d7c

Browse files
Pass through the test type so we can better handle paramterized tests
1 parent dc78268 commit 21c8d7c

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using GoogleTestAdapter.Model;
1313
using GoogleTestAdapter.Framework;
1414
using GoogleTestAdapter.Settings;
15+
using GoogleTestAdapter.TestCases;
1516

1617
namespace GoogleTestAdapter.Runners
1718
{
@@ -65,10 +66,10 @@ public void RunTests(IEnumerable<TestCase> testCasesToRun, string baseDir,
6566
{
6667
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
6768

68-
var testType = testCase.Traits.FirstOrDefault(t => t.Name.Equals("TestType"));
69+
var testType = testCase.Traits.FirstOrDefault(t => t.Name.Equals(nameof(TestCaseDescriptor.TestType)));
6970
// If it is a parameterized test, we should look for the "parent" key which doesn't have the suite or the id defined in the xml file.
7071
// The strategy for this can also be seen in the MethodSignatureCreate.cs file, going the other way.
71-
if (testType != null && testType.Value.Equals("Parameterized"))
72+
if (testType != null && testType.Value.Equals(TestCaseDescriptor.TestTypes.Parameterized))
7273
{
7374
int firstIndex = key.IndexOf("/");
7475
int lastIndex = key.LastIndexOf("/");

GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ private TestCase CreateTestCase(TestCaseDescriptor descriptor)
234234
var testCase = new TestCase(
235235
descriptor.FullyQualifiedName, descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, "", 0);
236236
testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, new List<Trait>()));
237+
testCase.Traits.Add(new Trait(nameof(TestCaseDescriptor.TestType), descriptor.TestType.ToString()));
237238
return testCase;
238239
}
239240

@@ -261,12 +262,15 @@ private TestCase CreateTestCase(TestCaseDescriptor descriptor, TestCaseLocation
261262
var testCase = new TestCase(
262263
descriptor.FullyQualifiedName, ns + descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, location.Sourcefile, (int)location.Line);
263264
testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, location.Traits));
265+
testCase.Traits.Add(new Trait(nameof(TestCaseDescriptor.TestType), descriptor.TestType.ToString()));
264266
return testCase;
265267
}
266268

267-
_logger.LogWarning(String.Format(Resources.LocationNotFoundError, descriptor.FullyQualifiedName));
268-
return new TestCase(
269+
var returnTest = new TestCase(
269270
descriptor.FullyQualifiedName, descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, "", 0);
271+
returnTest.Traits.Add(new Trait(nameof(TestCaseDescriptor.TestType), descriptor.TestType.ToString()));
272+
_logger.LogWarning(String.Format(Resources.LocationNotFoundError, descriptor.FullyQualifiedName));
273+
return returnTest;
270274
}
271275

272276
internal static string GetTestSignatureNamespace(string signature)

0 commit comments

Comments
 (0)