Ejemplo n.º 1
0
            public void Should_Capture_NUnit3()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/nunit3-console.exe");

                var nUnit3Settings = new NUnit3Settings
                {
                    ShadowCopy   = false,
                    Results      = "/Working/TestResult.xml",
                    ResultFormat = "nunit2",
                    Labels       = NUnit3Labels.All,
                    OutputFile   = "/Working/TestResult.txt"
                };

                fixture.Action = context =>
                {
                    context.NUnit3(new FilePath[] { "./Test.dll" }, nUnit3Settings);
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("nunitexecutionreport \"/Working/Tests.csproj\" " +
                             "/xmlTestResult:\"/Working/TestResult.xml\" " +
                             "/testOutput:\"/Working/TestResult.txt\"", result.Args);
            }
Ejemplo n.º 2
0
            public void Should_Capture_NUnit3_And_Throw_If_Labels_Is_Missing()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/nunit3-console.exe");

                var nUnit3Settings = new NUnit3Settings
                {
                    ShadowCopy   = false,
                    Results      = "/Working/TestResult.xml",
                    ResultFormat = "nunit2",
                    OutputFile   = "/Working/TestResult.txt"
                };

                fixture.Action = context =>
                {
                    context.NUnit3(new FilePath[] { "./Test.dll" }, nUnit3Settings);
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "NUnit3 must contain argument \"--labels=All\"");
            }
Ejemplo n.º 3
0
            public void Should_Capture_MSTest()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/MSTest.exe");

                var msTestSettings = new MSTestSettings
                {
                    NoIsolation = true
                };

                msTestSettings.ArgumentCustomization = builder => builder.Append("/resultsfile:/Working/TestResult.trx");
                msTestSettings.ToolPath = "/Working/tools/MSTest.exe";

                fixture.Action = context =>
                {
                    context.MSTest(new FilePath[] { "./Test.dll" }, msTestSettings);
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("mstestexecutionreport \"/Working/Tests.csproj\" " +
                             "/testResult:/Working/TestResult.trx", result.Args);
            }
Ejemplo n.º 4
0
            public void Should_Capture_MSTest_And_Throw_If_ResultsFile_Is_Missing()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/MSTest.exe");

                var msTestSettings = new MSTestSettings
                {
                    NoIsolation = true
                };

                msTestSettings.ToolPath = "/Working/tools/MSTest.exe";

                fixture.Action = context =>
                {
                    context.MSTest(new FilePath[] { "./Test.dll" }, msTestSettings);
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "MSTest must contain argument \"/resultsfile:<filename>\"");
            }
Ejemplo n.º 5
0
            public void Should_Capture_XUnit2()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/xunit.console.exe");

                var xUnit2Settings = new XUnit2Settings {
                    ShadowCopy = false
                };

                xUnit2Settings.ArgumentCustomization = builder => builder.Append("-nunit \"/Working/TestResult.xml\"");

                fixture.Action = context =>
                {
                    context.XUnit2(new FilePath[] { "./Test.dll" }, xUnit2Settings);
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("nunitexecutionreport \"/Working/Tests.csproj\" " +
                             "/xmlTestResult:\"/Working/TestResult.xml\"", result.Args);
            }
Ejemplo n.º 6
0
            public void Should_Rethrow_Exception_From_Action()
            {
                // Given
                var exception = new CakeException("The exception message");
                var fixture   = new SpecFlowTestExecutionReporterFixture();

                fixture.Settings.ThrowOnTestFailure = true;
                var intercepting = true;

                fixture.Action = context =>
                {
                    context.ProcessRunner.Start(
                        new FilePath("/Working/tools/MSTest.exe"),
                        new ProcessSettings()
                    {
                        Arguments = "/resultsfile:\"/Working/TestResult.trx\""
                    });

                    // Quick fix to avoid throwing exception while intercepting action
                    if (intercepting)
                    {
                        intercepting = false;
                    }
                    else
                    {
                        throw exception;
                    }
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, exception.Message);
            }
Ejemplo n.º 7
0
            public void Should_Capture_Tool_And_Arguments_From_Action()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("mstestexecutionreport \"/Working/Tests.csproj\" " +
                             "/testResult:\"/Working/TestResult.trx\"", result.Args);
            }
Ejemplo n.º 8
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "settings");
            }
Ejemplo n.º 9
0
            public void Should_Throw_If_No_Tool_Was_Intercepted()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Action = context => { };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "No tool was started.");
            }
Ejemplo n.º 10
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Context = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "context");
            }
Ejemplo n.º 11
0
            public void Should_Throw_If_Project_File_Is_Null()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.ProjectFile = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsArgumentNullException(result, "projectFile");
            }
Ejemplo n.º 12
0
            public void Should_Append_Out()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Settings.Out = "/Working/out.html";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("mstestexecutionreport \"/Working/Tests.csproj\" " +
                             "/testResult:\"/Working/TestResult.trx\" " +
                             "/out:\"/Working/out.html\"", result.Args);
            }
Ejemplo n.º 13
0
            public void Should_Append_XsltFile()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Settings.XsltFile = "/Working/template.xslt";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("mstestexecutionreport \"/Working/Tests.csproj\" " +
                             "/testResult:\"/Working/TestResult.trx\" " +
                             "/xsltFile:\"/Working/template.xslt\"", result.Args);
            }
Ejemplo n.º 14
0
            public void Should_Capture_XUnit2_And_Throw_If_NUnit_Is_Missing()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.FileSystem.CreateFile("/Working/tools/xunit.console.exe");

                fixture.Action = context =>
                {
                    context.XUnit2(new FilePath[] { "./Test.dll" }, new XUnit2Settings {
                        ShadowCopy = false
                    });
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "XUnit2 must contain argument \"-nunit <filename>\"");
            }
Ejemplo n.º 15
0
            public void Should_Throw_If_Action_Is_Not_Supported()
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Action = context =>
                {
                    context.ProcessRunner.Start(
                        new FilePath("/Working/tools/Test.exe"),
                        new ProcessSettings
                    {
                        Arguments = null
                    });
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "Unsupported tool /Working/tools/Test.exe.");
            }
Ejemplo n.º 16
0
            public void Should_Throw_If_Action_Does_Not_Contain_Arguments(string arguments)
            {
                // Given
                var fixture = new SpecFlowTestExecutionReporterFixture();

                fixture.Action = context =>
                {
                    context.ProcessRunner.Start(
                        new FilePath("/Working/tools/MSTest.exe"),
                        new ProcessSettings
                    {
                        Arguments = arguments
                    });
                };

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsCakeException(result, "No arguments were found for tool.");
            }
Ejemplo n.º 17
0
            public void Should_Not_Rethrow_Exception_From_Action()
            {
                // Given
                var exception = new CakeException("The exception message");
                var fixture   = new SpecFlowTestExecutionReporterFixture();

                fixture.Settings.ThrowOnTestFailure = false;
                var intercepting = true;

                fixture.Action = context =>
                {
                    var process = context.ProcessRunner.Start(
                        new FilePath("/Working/tools/MSTest.exe"),
                        new ProcessSettings()
                    {
                        Arguments = "/resultsfile:\"/Working/TestResult.trx\""
                    });

                    // Quick fix to avoid throwing exception while intercepting action
                    if (intercepting)
                    {
                        intercepting = false;
                    }
                    else
                    {
                        throw exception;
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("mstestexecutionreport \"/Working/Tests.csproj\" " +
                             "/testResult:\"/Working/TestResult.trx\"", result.Args);
            }