예제 #1
0
 _TestOutput ToTestOutput(
     Xunit1TestCase testCase,
     string output)
 {
     return(new _TestOutput
     {
         AssemblyUniqueID = testCase.AssemblyUniqueID,
         Output = output,
         TestCaseUniqueID = testCase.TestCaseUniqueID,
         TestClassUniqueID = testCase.TestClassUniqueID,
         TestCollectionUniqueID = testCase.TestCollectionUniqueID,
         TestMethodUniqueID = testCase.TestMethodUniqueID,
         TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex)
     });
 }
예제 #2
0
 _TestStarting ToTestStarting(
     Xunit1TestCase testCase,
     string testDisplayName)
 {
     return(new _TestStarting
     {
         AssemblyUniqueID = testCase.AssemblyUniqueID,
         TestCaseUniqueID = testCase.TestCaseUniqueID,
         TestClassUniqueID = testCase.TestClassUniqueID,
         TestCollectionUniqueID = testCase.TestCollectionUniqueID,
         TestDisplayName = testDisplayName,
         TestMethodUniqueID = testCase.TestMethodUniqueID,
         TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex)
     });
 }
예제 #3
0
 _TestSkipped ToTestSkipped(
     Xunit1TestCase testCase,
     string reason)
 {
     return(new _TestSkipped
     {
         AssemblyUniqueID = testCase.AssemblyUniqueID,
         ExecutionTime = 0m,
         Output = "",
         Reason = reason,
         TestCaseUniqueID = testCase.TestCaseUniqueID,
         TestClassUniqueID = testCase.TestClassUniqueID,
         TestCollectionUniqueID = testCase.TestCollectionUniqueID,
         TestMethodUniqueID = testCase.TestMethodUniqueID,
         TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex)
     });
 }
예제 #4
0
 _TestPassed ToTestPassed(
     Xunit1TestCase testCase,
     decimal executionTime,
     string output)
 {
     return(new _TestPassed
     {
         AssemblyUniqueID = testCase.AssemblyUniqueID,
         ExecutionTime = executionTime,
         Output = output,
         TestCaseUniqueID = testCase.TestCaseUniqueID,
         TestClassUniqueID = testCase.TestClassUniqueID,
         TestCollectionUniqueID = testCase.TestCollectionUniqueID,
         TestMethodUniqueID = testCase.TestMethodUniqueID,
         TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex)
     });
 }
예제 #5
0
        _TestFailed ToTestFailed(
            Xunit1TestCase testCase,
            decimal executionTime,
            string output,
            XmlNode failure)
        {
            var errorMetadata = Xunit1ExceptionUtility.ConvertToErrorMetadata(failure);

            return(new _TestFailed
            {
                AssemblyUniqueID = testCase.AssemblyUniqueID,
                ExceptionParentIndices = errorMetadata.ExceptionParentIndices,
                ExceptionTypes = errorMetadata.ExceptionTypes,
                ExecutionTime = executionTime,
                Messages = errorMetadata.Messages,
                Output = output,
                StackTraces = errorMetadata.StackTraces,
                TestCaseUniqueID = testCase.TestCaseUniqueID,
                TestClassUniqueID = testCase.TestClassUniqueID,
                TestCollectionUniqueID = testCase.TestCollectionUniqueID,
                TestMethodUniqueID = testCase.TestMethodUniqueID,
                TestUniqueID = UniqueIDGenerator.ForTest(testCase.TestCaseUniqueID, currentTestIndex)
            });
        }
예제 #6
0
 /// <summary>
 /// INTERNAL METHOD, FOR TESTING PURPOSES ONLY. DO NOT CALL.
 /// </summary>
 protected string Serialize(Xunit1TestCase testCase) =>
 SerializationHelper.Serialize(testCase);
예제 #7
0
        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);
                    }
                }
            }
        }