コード例 #1
0
ファイル: NUnitXmlReport.cs プロジェクト: JakeGinnivan/fixie
 static XElement Class(ClassResult classResult)
 {
     return new XElement("test-suite",
         new XAttribute("name", classResult.Name),
         new XAttribute("success", classResult.Failed == 0),
         new XAttribute("time", Seconds(classResult.Duration)),
         new XElement("results", classResult.CaseResults.Select(Case)));
 }
コード例 #2
0
ファイル: XUnitXmlReport.cs プロジェクト: leijiancd/fixie
 private static XElement Class(ClassResult classResult)
 {
     return new XElement("class",
         new XAttribute("time", Seconds(classResult.Duration)),
         new XAttribute("name", classResult.Name),
         new XAttribute("total", classResult.Failed + classResult.Passed + classResult.Skipped),
         new XAttribute("passed", classResult.Passed),
         new XAttribute("failed", classResult.Failed),
         new XAttribute("skipped", classResult.Skipped),
         classResult.CaseResults.Select(Case));
 }
コード例 #3
0
ファイル: NUnitXmlReport.cs プロジェクト: leijiancd/fixie
 static XElement Class(ClassResult classResult)
 {
     return new XElement("test-suite",
         new XAttribute("type", "TestFixture"),
         new XAttribute("name", classResult.Name),
         new XAttribute("success", classResult.Failed == 0),
         new XAttribute("time", Seconds(classResult.Duration)),
         new XAttribute("executed", true),
         new XAttribute("result", classResult.Failed > 0 ? "Failure" : "Success"),
         new XElement("results", classResult.CaseResults.Select(Case)));
 }
コード例 #4
0
ファイル: ConventionResult.cs プロジェクト: leijiancd/fixie
 public void Add(ClassResult classResult)
 {
     classResults.Add(classResult);
 }
コード例 #5
0
ファイル: ClassRunner.cs プロジェクト: jbogard/fixie
        public ClassResult Run(Type testClass)
        {
            var methods = methodDiscoverer.TestMethods(testClass);

            var cases = new List<Case>();

            foreach (var method in methods)
            {
                try
                {
                    bool generatedInputParameters = false;

                    foreach (var parameters in Parameters(method))
                    {
                        generatedInputParameters = true;
                        cases.Add(new Case(method, parameters));
                    }

                    if (!generatedInputParameters)
                    {
                        if (method.GetParameters().Length > 0)
                            throw new Exception("This test case has declared parameters, but no parameter values have been provided to it.");

                        cases.Add(new Case(method));
                    }
                }
                catch (Exception parameterGenerationException)
                {
                    var @case = new Case(method);
                    @case.Fail(parameterGenerationException);
                    cases.Add(@case);
                }
            }

            var orderedCases = cases.ToArray();
            try
            {
                orderCases(orderedCases);
            }
            catch (Exception exception)
            {
                // When an exception is thrown attempting to sort an array,
                // the behavior is undefined, so at this point orderedCases
                // is no longer reliable and needs to be fixed. The best we
                // can do is go with the original order.
                orderedCases = cases.ToArray();

                foreach (var @case in cases)
                    @case.Fail(exception);
            }

            var classResult = new ClassResult(testClass.FullName);

            var casesToExecute = new List<Case>();

            foreach (var @case in orderedCases)
            {
                if (@case.Exceptions.Any())
                    classResult.Add(Fail(@case));
                else
                {
                    string reason;
                    bool skipCase;

                    try
                    {
                        skipCase = SkipCase(@case, out reason);
                    }
                    catch (Exception exception)
                    {
                        @case.Fail(exception);
                        classResult.Add(Fail(@case));
                        continue;
                    }

                    if (skipCase)
                        classResult.Add(Skip(@case, reason));
                    else
                        casesToExecute.Add(@case);
                }
            }

            if (casesToExecute.Any())
            {
                Run(testClass, casesToExecute);

                foreach (var @case in casesToExecute)
                    classResult.Add(@case.Exceptions.Any() ? Fail(@case) : Pass(@case));
            }

            return classResult;
        }
コード例 #6
0
ファイル: ClassRunner.cs プロジェクト: JohnStov/fixie
        public ClassResult Run(Type testClass)
        {
            var methods = methodDiscoverer.TestMethods(testClass);

            var cases = new List<Case>();
            var parameterGenerationFailures = new List<Case>();

            foreach (var method in methods)
            {
                try
                {
                    bool methodHasParameterizedCase = false;

                    foreach (var parameters in Parameters(method))
                    {
                        methodHasParameterizedCase = true;
                        cases.Add(new Case(method, parameters));
                    }

                    if (!methodHasParameterizedCase)
                        cases.Add(new Case(method));
                }
                catch (Exception parameterGenerationException)
                {
                    var @case = new Case(method);
                    @case.Fail(parameterGenerationException);
                    parameterGenerationFailures.Add(@case);
                }
            }

            var casesToSkipList = new List<KeyValuePair<Case, string>>();
            var casesToExecuteList = new List<Case>();
            foreach (var @case in cases)
            {
                string reason;
                if (SkipCase(@case, out reason))
                    casesToSkipList.Add(new KeyValuePair<Case, string>(@case, reason));
                else
                    casesToExecuteList.Add(@case);
            }

            var casesToSkip = casesToSkipList.Select(x => x.Key).ToArray();
            var casesToExecute = casesToExecuteList.ToArray();

            var classResult = new ClassResult(testClass.FullName);

            if (casesToSkip.Any())
            {
                TryOrderCases(casesToSkip);

                foreach (var @case in casesToSkip)
                    classResult.Add(Skip(@case, casesToSkipList.Single(x => x.Key == @case).Value));
            }

            if (casesToExecute.Any())
            {
                if (TryOrderCases(casesToExecute))
                    Run(testClass, casesToExecute);

                foreach (var @case in casesToExecute)
                    classResult.Add(@case.Exceptions.Any() ? Fail(@case) : Pass(@case));
            }

            if (parameterGenerationFailures.Any())
            {
                var casesToFailWithoutRunning = parameterGenerationFailures.ToArray();

                TryOrderCases(casesToFailWithoutRunning);

                foreach (var caseToFailWithoutRunning in casesToFailWithoutRunning)
                    classResult.Add(Fail(caseToFailWithoutRunning));
            }

            return classResult;
        }
コード例 #7
0
ファイル: ConventionResult.cs プロジェクト: vgrigoriu/fixie
 public void Add(ClassResult classResult)
 {
     classResults.Add(classResult);
 }
コード例 #8
0
ファイル: ClassRunner.cs プロジェクト: JakeGinnivan/fixie
        public ClassResult Run(Type testClass)
        {
            var methods = methodDiscoverer.TestMethods(testClass);

            var cases = new List<Case>();
            var parameterGenerationFailures = new List<Case>();

            foreach (var method in methods)
            {
                try
                {
                    bool methodHasParameterizedCase = false;

                    foreach (var parameters in Parameters(method))
                    {
                        methodHasParameterizedCase = true;
                        cases.Add(new Case(method, parameters));
                    }

                    if (!methodHasParameterizedCase)
                        cases.Add(new Case(method));
                }
                catch (Exception parameterGenerationException)
                {
                    var @case = new Case(method);
                    @case.Fail(parameterGenerationException);
                    parameterGenerationFailures.Add(@case);
                }
            }

            var casesBySkipState = cases.ToLookup(SkipCase);
            var casesToSkip = casesBySkipState[true].ToArray();
            var casesToExecute = casesBySkipState[false].ToArray();

            var classResult = new ClassResult(testClass.FullName);

            if (casesToSkip.Any())
            {
                TryOrderCases(casesToSkip);

                foreach (var @case in casesToSkip)
                    classResult.Add(Skip(@case));
            }

            if (casesToExecute.Any())
            {
                if (TryOrderCases(casesToExecute))
                    Run(testClass, casesToExecute);

                foreach (var @case in casesToExecute)
                    classResult.Add(@case.Exceptions.Any() ? Fail(@case) : Pass(@case));
            }

            if (parameterGenerationFailures.Any())
            {
                var casesToFailWithoutRunning = parameterGenerationFailures.ToArray();

                TryOrderCases(casesToFailWithoutRunning);

                foreach (var caseToFailWithoutRunning in casesToFailWithoutRunning)
                    classResult.Add(Fail(caseToFailWithoutRunning));
            }

            return classResult;
        }