private TestCase CreateTestCase(TestCaseDescriptor descriptor, TestCaseResolver resolver) { TestCaseLocation location = resolver.FindTestCaseLocation(_signatureCreator.GetTestMethodSignatures(descriptor).ToList()); return(CreateTestCase(descriptor, location)); }
private IEnumerable <string> GetTypedTestMethodSignatures(TestCaseDescriptor descriptor) { var result = new List <string>(); // remove instance number string suite = descriptor.Suite.Substring(0, descriptor.Suite.LastIndexOf("/", StringComparison.Ordinal)); // remove prefix if (suite.Contains("/")) { int index = suite.IndexOf("/", StringComparison.Ordinal); suite = suite.Substring(index + 1, suite.Length - index - 1); } string typeParam = "<.+>"; // <testcase name>_<test name>_Test<type param value>::TestBody result.Add(GetTestMethodSignature(suite, descriptor.Name, typeParam)); // gtest_case_<testcase name>_::<test name><type param value>::TestBody string signature = $"gtest_case_{suite}_::{descriptor.Name}{typeParam}{GoogleTestConstants.TestBodySignature}"; result.Add(signature); return(result); }
private IEnumerable<string> GetTypedTestMethodSignatures(TestCaseDescriptor descriptor) { var result = new List<string>(); // remove instance number string suite = descriptor.Suite.Substring(0, descriptor.Suite.LastIndexOf("/", StringComparison.Ordinal)); // remove prefix if (suite.Contains("/")) { int index = suite.IndexOf("/", StringComparison.Ordinal); suite = suite.Substring(index + 1, suite.Length - index - 1); } string typeParam = "<.+>"; // <testcase name>_<test name>_Test<type param value>::TestBody result.Add(GetTestMethodSignature(suite, descriptor.Name, typeParam)); // gtest_case_<testcase name>_::<test name><type param value>::TestBody string signature = $"gtest_case_{suite}_::{descriptor.Name}{typeParam}{GoogleTestConstants.TestBodySignature}"; result.Add(signature); return result; }
private TestCase CreateTestCase(TestCaseDescriptor descriptor) { var testCase = new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, "", 0); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, new List<Trait>())); return testCase; }
private TestCase CreateTestCase(TestCaseDescriptor descriptor) { var testCase = new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, "", 0); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, new List <Trait>())); return(testCase); }
private string GetParameterizedTestMethodSignature(TestCaseDescriptor descriptor) { // remove instance number int index = descriptor.Suite.IndexOf('/'); string suite = index < 0 ? descriptor.Suite : descriptor.Suite.Substring(index + 1); index = descriptor.Name.IndexOf('/'); string testName = index < 0 ? descriptor.Name : descriptor.Name.Substring(0, index); return GetTestMethodSignature(suite, testName); }
private string GetParameterizedTestMethodSignature(TestCaseDescriptor descriptor) { // remove instance number int index = descriptor.Suite.IndexOf('/'); string suite = index < 0 ? descriptor.Suite : descriptor.Suite.Substring(index + 1); index = descriptor.Name.IndexOf('/'); string testName = index < 0 ? descriptor.Name : descriptor.Name.Substring(0, index); return(GetTestMethodSignature(suite, testName)); }
private TestCase CreateTestCase(TestCaseDescriptor descriptor, TestCaseLocation location) { if (location != null) { var testCase = new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, location.Sourcefile, (int)location.Line); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, location.Traits)); return(testCase); } _logger.LogWarning(String.Format(Resources.LocationNotFoundError, descriptor.FullyQualifiedName)); return(CreateTestCase(descriptor)); }
internal IEnumerable <string> GetTestMethodSignatures(TestCaseDescriptor descriptor) { if (descriptor.TypeParam != null) { return(GetTypedTestMethodSignatures(descriptor)); } if (descriptor.Param != null) { return(GetParameterizedTestMethodSignature(descriptor).Yield()); } return(GetTestMethodSignature(descriptor.Suite, descriptor.Name).Yield()); }
private TestCase CreateTestCase(TestCaseDescriptor descriptor, TestCaseLocation location) { if (location != null) { var testCase = new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, location.Sourcefile, (int)location.Line); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, location.Traits)); return(testCase); } _logger.LogWarning($"Could not find source location for test {descriptor.FullyQualifiedName}, executable: {_executable}"); return(CreateTestCase(descriptor)); }
internal IEnumerable<string> GetTestMethodSignatures(TestCaseDescriptor descriptor) { switch (descriptor.TestType) { case TestCaseDescriptor.TestTypes.TypeParameterized: return GetTypedTestMethodSignatures(descriptor); case TestCaseDescriptor.TestTypes.Parameterized: return GetParameterizedTestMethodSignature(descriptor).Yield(); case TestCaseDescriptor.TestTypes.Simple: return GetTestMethodSignature(descriptor.Suite, descriptor.Name).Yield(); default: throw new InvalidOperationException($"Unknown literal {descriptor.TestType}"); } }
public IEnumerable<MethodSignature> GetTestMethodSignatures(TestCaseDescriptor descriptor) { switch (descriptor.TestType) { case TestCaseDescriptor.TestTypes.TypeParameterized: return GetTypedTestMethodSignatures(descriptor); case TestCaseDescriptor.TestTypes.Parameterized: return GetParameterizedTestMethodSignature(descriptor).Yield(); case TestCaseDescriptor.TestTypes.Simple: return GetTestMethodSignature(descriptor.Suite, descriptor.Name).Yield(); default: throw new InvalidOperationException($"Unknown literal {descriptor.TestType}"); } }
private TestCase CreateTestCase(TestCaseDescriptor descriptor, Dictionary <string, TestCaseLocation> testCaseLocations) { var signature = _signatureCreator.GetTestMethodSignatures(descriptor) .Select(StripTestSymbolNamespace) .FirstOrDefault(s => testCaseLocations.ContainsKey(s)); TestCaseLocation location = null; if (signature != null) { testCaseLocations.TryGetValue(signature, out location); } return(CreateTestCase(descriptor, location)); }
private TestCase CreateTestCase(TestCaseDescriptor descriptor, List <TestCaseLocation> testCaseLocations) { TestCaseLocation location = testCaseLocations.FirstOrDefault( l => SignatureCreator.GetTestMethodSignatures(descriptor).Any(s => l.Symbol.Contains(s))); if (location != null) { var testCase = new TestCase( descriptor.FullyQualifiedName, Executable, descriptor.DisplayName, location.Sourcefile, (int)location.Line); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, location.Traits)); return(testCase); } TestEnvironment.LogWarning($"Could not find source location for test {descriptor.FullyQualifiedName}"); return(new TestCase( descriptor.FullyQualifiedName, Executable, descriptor.DisplayName, "", 0)); }
internal IEnumerable <string> GetTestMethodSignatures(TestCaseDescriptor descriptor) { switch (descriptor.TestType) { case TestCaseDescriptor.TestTypes.TypeParameterized: return(GetTypedTestMethodSignatures(descriptor)); case TestCaseDescriptor.TestTypes.Parameterized: return(GetParameterizedTestMethodSignature(descriptor).Yield()); case TestCaseDescriptor.TestTypes.Simple: return(GetTestMethodSignature(descriptor.Suite, descriptor.Name).Yield()); default: throw new InvalidOperationException(String.Format(Resources.UnknownLiteral, descriptor.TestType)); } }
private TestCase CreateTestCase(TestCaseDescriptor descriptor, List<TestCaseLocation> testCaseLocations) { TestCaseLocation location = testCaseLocations.FirstOrDefault( l => _signatureCreator.GetTestMethodSignatures(descriptor).Any(s => Regex.IsMatch(l.Symbol, s))); if (location != null) { var testCase = new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, location.Sourcefile, (int)location.Line); testCase.Traits.AddRange(GetFinalTraits(descriptor.DisplayName, location.Traits)); return testCase; } _testEnvironment.LogWarning($"Could not find source location for test {descriptor.FullyQualifiedName}"); return new TestCase( descriptor.FullyQualifiedName, _executable, descriptor.DisplayName, "", 0); }
public void ReportLine(string line) { string trimmedLine = line.Trim('.', '\n', '\r'); if (trimmedLine.StartsWith(" ")) { TestCaseDescriptor descriptor = CreateDescriptor(_currentSuite, trimmedLine.Substring(2)); TestCaseDescriptorCreated?.Invoke(this, new TestCaseDescriptorCreatedEventArgs { TestCaseDescriptor = descriptor }); } else { _currentSuite = trimmedLine; } }
private void AssertCorrectTestLocationIsFound(string suite, uint line) { var descriptor = new TestCaseDescriptor( suite, "Test", $"{suite}.Test", $"{suite}.Test", TestCaseDescriptor.TestTypes.Simple); var signatures = new MethodSignatureCreator().GetTestMethodSignatures(descriptor); var resolver = new TestCaseResolver(TestResources.Tests_ReleaseX64, new DefaultDiaResolverFactory(), MockOptions.Object, _fakeLogger); var testCaseLocation = resolver.FindTestCaseLocation(signatures.ToList()); _fakeLogger.Errors.Should().BeEmpty(); testCaseLocation.Should().NotBeNull(); testCaseLocation.Sourcefile.Should().EndWithEquivalent(@"sampletests\tests\namespacetests.cpp"); testCaseLocation.Line.Should().Be(line); }