Exemplo n.º 1
0
        static void ProduceReports(ILookup <string, string> options, ExecutionResult executionResult)
        {
            if (options.Contains(CommandLineOption.NUnitXml))
            {
                var report = new NUnitXmlReport();

                var xDocument = report.Transform(executionResult);

                foreach (var fileName in options[CommandLineOption.NUnitXml])
                {
                    xDocument.Save(fileName, SaveOptions.None);
                }
            }

            if (options.Contains(CommandLineOption.XUnitXml))
            {
                var report = new XUnitXmlReport();

                var xDocument = report.Transform(executionResult);

                foreach (var fileName in options[CommandLineOption.XUnitXml])
                {
                    xDocument.Save(fileName, SaveOptions.None);
                }
            }
        }
Exemplo n.º 2
0
        protected override void Before_all_tests()
        {
            base.Before_all_tests();

            Func <ResultType, ExceptionInfo, TestCaseResult> getResult = (resultType, exceptionInfo) =>
            {
                return(new TestCaseResult(resultType)
                {
                    ClassName = "class_name",
                    MethodName = "method_name",
                    NamespaceName = "namespace.here",
                    Finished = new DateTime(2009, 2, 2, 2, 2, 2),
                    Started = new DateTime(2009, 2, 2, 2, 2, 1),
                    ExceptionInfo = exceptionInfo,
                });
            };

            var testReport = new TestReport("Test.xap")
                             .AddResult(getResult(ResultType.Passed, null))
                             .AddResult(getResult(ResultType.Failed, new ExceptionInfo(GetException())))
                             .AddResult(getResult(ResultType.Ignored, null))
                             .AddResult(getResult(ResultType.SystemGeneratedFailure, new ExceptionInfo(new Exception("fail"))))
            ;

            _xmlReport = new NUnitXmlReport(testReport.ToTestReportCollection());
        }
Exemplo n.º 3
0
        public void Should_pass_the_schema_validation()
        {
            var file = Path.GetTempFileName();

            using (TextWriter tw = new StreamWriter(file))
            {
                tw.Write(_xmlReport.GetXmlReport());
            }

            IList <string> errors;

            if (!NUnitXmlReport.ValidateSchema(file, out errors))
            {
                var msg = string.Join(Environment.NewLine, errors.ToArray());
                Assert.Fail(msg);
            }
        }
Exemplo n.º 4
0
        public void ShouldProduceValidXmlDocument()
        {
            var listener = new StubListener();
            var runner   = new Runner(listener);

            var executionResult = new ExecutionResult();
            var convention      = SelfTestConvention.Build();

            convention.CaseExecution.Skip(x => x.Method.Has <SkipAttribute>(), x => x.Method.GetCustomAttribute <SkipAttribute>().Reason);
            convention.Parameters.Add <InputAttributeParameterSource>();
            var assemblyResult = runner.RunTypes(GetType().Assembly, convention, typeof(PassFailTestClass));

            executionResult.Add(assemblyResult);

            var report = new NUnitXmlReport();
            var actual = report.Transform(executionResult);

            XsdValidate(actual);
            CleanBrittleValues(actual.ToString(SaveOptions.DisableFormatting)).ShouldEqual(ExpectedReport);
        }
Exemplo n.º 5
0
        static void SaveReport(Options options, ExecutionResult executionResult)
        {
            if (options.Contains(CommandLineOption.NUnitXml))
            {
                var xDocument = new NUnitXmlReport().Transform(executionResult);

                foreach (var fileName in options[CommandLineOption.NUnitXml])
                {
                    xDocument.Save(fileName, SaveOptions.None);
                }
            }

            if (options.Contains(CommandLineOption.XUnitXml))
            {
                var xDocument = new XUnitXmlReport().Transform(executionResult);

                foreach (var fileName in options[CommandLineOption.XUnitXml])
                {
                    xDocument.Save(fileName, SaveOptions.None);
                }
            }
        }
Exemplo n.º 6
0
        public void Should_not_throw_any_exceptions_if_there_are_no_tests()
        {
            NUnitXmlReport xmlReport = new NUnitXmlReport(new TestReport("Test.xap").ToTestReportCollection());

            xmlReport.GetXmlReport().ShouldNotBeEmpty();
        }