Ejemplo n.º 1
0
            public void Should_Throw_If_Assembly_Path_Is_Null()
            {
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                var result = Record.Exception(() => runner.Run(null, new XUnitSettings()));

                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("assemblyPath", ((ArgumentNullException)result).ParamName);
            }
Ejemplo n.º 2
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

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

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
Ejemplo n.º 3
0
            public void Should_Find_XUnit_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

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

                // Then
                Assert.Equal("/Working/tools/xunit.console.clr4.exe", result.Path.FullPath);
            }
Ejemplo n.º 4
0
            public void Should_Use_Provided_Assembly_Paths_In_Process_Arguments()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\"", result.Args);
            }
Ejemplo n.º 5
0
            public void Should_Throw_If_Assembly_Path_Is_Null()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(null, new XUnitSettings()));

                // Then
                Assert.IsArgumentNullException(result, "assemblyPath");
            }
Ejemplo n.º 6
0
            public void Should_Throw_If_Assembly_Path_Is_Null()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.AssemblyPath = null;

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

                // Then
                Assert.IsArgumentNullException(result, "assemblyPath");
            }
Ejemplo n.º 7
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings());

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.WorkingDirectory == "/Working"));
            }
Ejemplo n.º 8
0
            public void Should_Use_Provided_Assembly_Paths_In_Process_Arguments()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings());

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "\"/Working/Test1.dll\""));
            }
Ejemplo n.º 9
0
            public void Should_Find_XUnit_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings());

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.FileName == "/Working/tools/xunit.console.clr4.exe"));
            }
Ejemplo n.º 10
0
            public void Should_Not_Use_Shadow_Copying_If_Disabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.ShadowCopy = false;

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\" \"/noshadow\"", result.Args);
            }
Ejemplo n.º 11
0
            public void Should_Set_Silent_Mode_If_Enabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.Silent = true;

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\" /silent", result.Args);
            }
Ejemplo n.º 12
0
            public void Should_Throw_If_XUnit_Runner_Was_Not_Found()
            {
                // Given
                var fixture = new XUnitRunnerFixture(defaultToolExist: false);
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run("./Test1.dll", new XUnitSettings()));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Could not locate executable.", result.Message);
            }
Ejemplo n.º 13
0
            public void Should_Generate_Xml_Report_With_Correct_Name_For_Single_Assembly()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.OutputDirectory = "/Output";
                fixture.Settings.XmlReport       = true;

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\" \"/xml\" \"/Output/Test1.dll.xml\"", result.Args);
            }
Ejemplo n.º 14
0
            public void Should_Use_XUnit_Runner_From_Tool_Path_If_Provided_On_Windows(string toolPath, string expected)
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.ToolPath = toolPath;
                fixture.GivenSettingsToolPathExist();

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
Ejemplo n.º 15
0
            public void Should_Generate_Xml_Report_If_Enabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.OutputDirectory = "/Output";
                fixture.Settings.XmlReport       = true;

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\" \"/xml\" \"/Output/Test1.dll.xml\"", result.Args);
            }
Ejemplo n.º 16
0
            public void Should_Throw_If_XUnit_Runner_Was_Not_Found()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Could not locate executable.", result.Message);
            }
Ejemplo n.º 17
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.GivenProcessExitsWithCode(1);

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Process returned an error (exit code 1).", result.Message);
            }
Ejemplo n.º 18
0
            public void Should_Throw_If_XmlReport_Is_Set_But_OutputDirectory_Is_Null()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Settings.XmlReport = true;

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Cannot generate XML report when no output directory has been set.", result.Message);
            }
Ejemplo n.º 19
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.GivenProcessCannotStart();

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Process was not started.", result.Message);
            }
Ejemplo n.º 20
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.ProcessRunner.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()).Returns((IProcess)null);
                var runner = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run("./Test1.dll", new XUnitSettings()));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Process was not started.", result.Message);
            }
Ejemplo n.º 21
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.Process.GetExitCode().Returns(1);
                var runner = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run("./Test1.dll", new XUnitSettings()));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("xUnit.net (v1): Process returned an error.", result.Message);
            }
Ejemplo n.º 22
0
            public void Should_Not_Use_Shadow_Copying_If_Disabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings
                {
                    ShadowCopy = false
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "\"/Working/Test1.dll\" \"/noshadow\""));
            }
Ejemplo n.º 23
0
            public void Should_Use_XUnit_Runner_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new XUnitRunnerFixture(expected);
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings
                {
                    ToolPath = toolPath
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.FileName == expected));
            }
Ejemplo n.º 24
0
            public void Should_Throw_If_HtmlReport_Is_Set_But_OutputDirectory_Is_Null()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run("./Test1.dll", new XUnitSettings
                {
                    HtmlReport = true
                }));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Cannot generate HTML report when no output directory has been set.", result.Message);
            }
Ejemplo n.º 25
0
            public void Should_Generate_Xml_Report_With_Correct_Name_For_Multiple_Assemblies()
            {
                // Given
                var fixture = new XUnitRunnerFixture();

                fixture.AssemblyPaths            = new FilePath[] { "./Test1.dll", "./Test2.dll" };
                fixture.Settings.OutputDirectory = "/Output";
                fixture.Settings.XmlReport       = true;

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

                // Then
                Assert.Equal("\"/Working/Test1.dll\" \"/Working/Test2.dll\" " +
                             "\"/xml\" \"/Output/TestResults.xml\"", result.Args);
            }
Ejemplo n.º 26
0
            public void Should_Generate_Xml_Report_If_Enabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings
                {
                    OutputDirectory = "/Output",
                    XmlReport       = true
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "\"/Working/Test1.dll\" \"/xml\" \"/Output/Test1.dll.xml\""));
            }
Ejemplo n.º 27
0
            public void Should_Set_Silent_Mode_If_Enabled_In_Settings()
            {
                // Given
                var fixture = new XUnitRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run("./Test1.dll", new XUnitSettings
                {
                    Silent = true
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(p =>
                                             p.Arguments.Render() == "\"/Working/Test1.dll\" /silent"));
            }