/// <inheritdoc/> public ISourceInformation?GetSourceInformation(ITestCase testCase) { var className = testCase?.TestMethod?.TestClass?.Class?.Name; var methodName = testCase?.TestMethod?.Method?.Name; if (className == null || methodName == null) { return(null); } var sourceInfo = v3Provider.GetSourceInformation(className, methodName); return(new SourceInformation { FileName = sourceInfo.FileName, LineNumber = sourceInfo.LineNumber }); }
void Find( bool includeSourceInformation, Action <Xunit1TestCase> callback) { XmlNode?assemblyXml = null; var handler = new XmlNodeCallbackHandler(xml => { assemblyXml = xml; return(true); }); Executor.EnumerateTests(handler); if (assemblyXml != null) { var methodNodes = assemblyXml.SelectNodes("//method")?.Cast <XmlNode>(); if (methodNodes != null) { foreach (var methodXml in methodNodes) { var typeName = methodXml.Attributes?["type"]?.Value; var methodName = methodXml.Attributes?["method"]?.Value; if (typeName == null || methodName == null) { continue; } string?displayName = null; var displayNameAttribute = methodXml.Attributes?["name"]; if (displayNameAttribute != null) { displayName = displayNameAttribute.Value; } string?skipReason = null; var skipReasonAttribute = methodXml.Attributes?["skip"]; if (skipReasonAttribute != null) { skipReason = skipReasonAttribute.Value; } var traits = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase); var traitNodes = methodXml.SelectNodes("traits/trait")?.Cast <XmlNode>(); if (traitNodes != null) { foreach (var traitNode in traitNodes) { var traitName = traitNode.Attributes?["name"]?.Value; var traitValue = traitNode.Attributes?["value"]?.Value; if (traitName != null && traitValue != null) { traits.Add(traitName, traitValue); } } } var sourceInformation = default(_ISourceInformation); if (includeSourceInformation) { sourceInformation = sourceInformationProvider.GetSourceInformation(typeName, methodName); } var testCase = new Xunit1TestCase { AssemblyUniqueID = TestAssemblyUniqueID, SkipReason = skipReason, SourceFilePath = sourceInformation?.FileName, SourceLineNumber = sourceInformation?.LineNumber, TestCaseDisplayName = displayName ?? $"{typeName}.{methodName}", TestCaseUniqueID = $":v1:case:{typeName}.{methodName}:{assemblyFileName}:{configFileName ?? "(null)"}", TestClass = typeName, TestClassUniqueID = $":v1:class:{typeName}:{assemblyFileName}:{configFileName ?? "(null)"}", TestCollectionUniqueID = $":v1:collection:{assemblyFileName}:{configFileName ?? "(null)"}", TestMethod = methodName, TestMethodUniqueID = $":v1:method:{typeName}.{methodName}:{assemblyFileName}:{configFileName ?? "(null)"}", Traits = traits }; callback(testCase); } } } }