Пример #1
0
            public void Should_Publish_Test_Results_If_File_Path_Is_Absolute_Windows()
            {
                const string expected = @"##vso[results.publish type=XUnit;mergeResults=true;platform=x86;config=Debug;runTitle='Cake Test Run 1 [master]';publishRunAttachments=true;resultFiles=C:\build\CAKE-CAKE-JOB1\artifacts\resultsXUnit.trx,C:\build\CAKE-CAKE-JOB1\artifacts\resultsJs.trx;]";

                // Given
                var fixture = new AzurePipelinesFixture();
                var service = fixture.CreateAzurePipelinesService();
                var data    = new AzurePipelinesPublishTestResultsData
                {
                    Configuration         = "Debug",
                    MergeTestResults      = true,
                    Platform              = "x86",
                    PublishRunAttachments = true,
                    TestRunner            = AzurePipelinesTestRunnerType.XUnit,
                    TestRunTitle          = "Cake Test Run 1 [master]",
                    TestResultsFiles      = new FilePath[]
                    {
                        "C:\\build\\CAKE-CAKE-JOB1\\artifacts\\resultsXUnit.trx",
                        "C:\\build\\CAKE-CAKE-JOB1\\artifacts\\resultsJs.trx"
                    }
                };

                // When
                service.Commands.PublishTestResults(data);

                // Then
                Assert.Equal(expected.Replace('/', System.IO.Path.DirectorySeparatorChar), fixture.Writer.Entries.FirstOrDefault());
            }
Пример #2
0
            public void Should_Publish_Test_Results_If_File_Path_Is_Absolute()
            {
                // Given
                var fixture = new AzurePipelinesFixture();

                fixture.Environment.WorkingDirectory.Returns("/build/CAKE-CAKE-JOB1");
                fixture.Environment.Platform.Family.Returns(PlatformFamily.OSX);
                var service = fixture.CreateAzurePipelinesService();
                var data    = new AzurePipelinesPublishTestResultsData
                {
                    Configuration         = "Debug",
                    MergeTestResults      = true,
                    Platform              = "x86",
                    PublishRunAttachments = true,
                    TestRunner            = AzurePipelinesTestRunnerType.XUnit,
                    TestRunTitle          = "Cake Test Run 1 [master]",
                    TestResultsFiles      = new FilePath[]
                    {
                        "/build/CAKE-CAKE-JOB1/artifacts/resultsXUnit.trx",
                        "/build/CAKE-CAKE-JOB1/artifacts/resultsJs.trx"
                    }
                };

                // When
                service.Commands.PublishTestResults(data);

                // Then
                const string expected = @"##vso[results.publish type=XUnit;mergeResults=true;platform=x86;config=Debug;runTitle='Cake Test Run 1 [master]';publishRunAttachments=true;resultFiles=/build/CAKE-CAKE-JOB1/artifacts/resultsXUnit.trx,/build/CAKE-CAKE-JOB1/artifacts/resultsJs.trx;]";
                var          actual   = fixture.Log.Entries.FirstOrDefault();

                Assert.Equal(expected.Replace('/', System.IO.Path.DirectorySeparatorChar), actual?.Message);
            }
Пример #3
0
    public override void Finally(BuildContext context)
    {
        var testResultsFiles = context.GetFiles($"{Paths.TestOutput}/*.results.xml");

        if (!context.IsAzurePipelineBuild || !testResultsFiles.Any())
        {
            return;
        }

        var data = new AzurePipelinesPublishTestResultsData
        {
            TestResultsFiles = testResultsFiles.ToArray(),
            Platform         = context.Environment.Platform.Family.ToString(),
            TestRunner       = AzurePipelinesTestRunnerType.NUnit
        };

        context.BuildSystem().AzurePipelines.Commands.PublishTestResults(data);
    }
Пример #4
0
        /// <inheritdoc/>
        public void PublishTestResults(AzurePipelinesPublishTestResultsData data)
        {
            var properties = data.GetProperties(_environment);

            WriteLoggingCommand("results.publish", properties, string.Empty);
        }