Skip to content

Commit be2dcac

Browse files
add logic to fix the key for parameterized tests
1 parent e9c1e54 commit be2dcac

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 8 additions & 3 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
{
@@ -69,10 +70,14 @@ public void RunTests(IEnumerable<TestCase> testCasesToRun, string baseDir,
6970
{
7071
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
7172

72-
var testType = testCase.Traits.FirstOrDefault(t => t.Name.Equals("TestType"));
73-
if (testType != null && testType.Value.Equals("Parameterized"))
73+
var testType = testCase.Traits.FirstOrDefault(t => t.Name.Equals(nameof(TestCaseDescriptor.TestType)));
74+
// 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.
75+
// The strategy for this can also be seen in the MethodSignatureCreate.cs file, going the other way.
76+
if (testType != null && testType.Value.Equals(TestCaseDescriptor.TestTypes.Parameterized))
7477
{
75-
key = "*/BadWorkingDirTestFixture.BadWorkingDirTest/*";
78+
int firstIndex = key.IndexOf("/");
79+
int lastIndex = key.LastIndexOf("/");
80+
key = string.Concat("*", key.Substring(firstIndex, lastIndex - firstIndex), "/*");
7681
}
7782

7883
ITestPropertySettings settings;

0 commit comments

Comments
 (0)