コード例 #1
0
 public void It_builds_the_project_using_the_build_base_path_passed()
 {
     var buildBasePath = GetNotSoLongBuildBasePath();
     var testCommand = new DotnetTestCommand();
     var result = testCommand.Execute($"{_projectFilePath} -b {buildBasePath}");
     result.Should().Pass();
 }
コード例 #2
0
 //ISSUE https://github.com/dotnet/cli/issues/1935
 // This fact technically succeeds on Windows, but it causes a crash dialog to pop, which interrupts the build.
 //[WindowsOnlyFact]
 public void It_returns_a_failure_when_it_fails_to_run_the_tests()
 {
     var testCommand = new DotnetTestCommand();
     var result = testCommand.Execute(
         $"{_projectFilePath} -o {Path.Combine(AppContext.BaseDirectory, "nonExistingFolder")} --no-build");
     result.Should().Fail();
 }
コード例 #3
0
 public void It_builds_the_project_using_the_output_passed()
 {
     var testCommand = new DotnetTestCommand();
     var result = testCommand.Execute(
         $"{_projectFilePath} -o {Path.Combine(AppContext.BaseDirectory, "output")} -f netcoreapp1.0");
     result.Should().Pass();
 }
 public void It_builds_and_runs_tests_for_netcoreapp10()
 {
     var testCommand = new DotnetTestCommand();
     var result = testCommand
         .ExecuteWithCapturedOutput($"{_projectFilePath} -f netcoreapp1.0");
     result.Should().Pass();
     result.StdOut.Should().Contain($"Skipped for NETCOREAPP1.0");
     result.StdOut.Should().NotContain($"Skipped for NET451");
 }
コード例 #5
0
        public void It_skips_build_when_the_no_build_flag_is_passed()
        {
            var buildCommand = new BuildCommand(_projectFilePath);
            var result = buildCommand.Execute();
            result.Should().Pass();

            var testCommand = new DotnetTestCommand();
            result = testCommand.Execute($"{_projectFilePath} -o {_defaultOutputPath} --no-build");
            result.Should().Pass();
        }
        public void It_discovers_two_tests_for_the_ProjectWithTests()
        {
            using (var adapter = new Adapter("TestDiscovery.Start"))
            {
                adapter.Listen();

                var testCommand = new DotnetTestCommand();
                var result = testCommand.Execute($"{_projectFilePath} -o {_outputPath} --port {adapter.Port} --no-build");
                result.Should().Pass();

                adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
                adapter.Messages["TestDiscovery.TestFound"].Count.Should().Be(2);
                adapter.Messages["TestDiscovery.Completed"].Count.Should().Be(1);
            }
        }
        public void It_runs_two_tests_for_the_ProjectWithTests()
        {
            using (var adapter = new Adapter("TestExecution.GetTestRunnerProcessStartInfo"))
            {
                adapter.Listen();

                var testCommand = new DotnetTestCommand();
                var result = testCommand.Execute($"{_projectFilePath} -o {_outputPath} --port {adapter.Port} --no-build");
                result.Should().Pass();

                adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
                adapter.Messages["TestExecution.TestRunnerProcessStartInfo"].Count.Should().Be(1);
                adapter.Messages["TestExecution.TestStarted"].Count.Should().Be(2);
                adapter.Messages["TestExecution.TestResult"].Count.Should().Be(2);
                adapter.Messages["TestExecution.Completed"].Count.Should().Be(1);
            }
        }
        public void It_discovers_tests_for_the_ProjectWithTestsWithNet451()
        {
            Setup();

            using (var adapter = new Adapter("TestDiscovery.Start"))
            {
                adapter.Listen();
                var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();

                var testCommand = new DotnetTestCommand();
                var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build");
                result.Should().Pass();

                adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
                adapter.Messages["TestDiscovery.TestFound"].Count.Should().Be(4);
                adapter.Messages["TestDiscovery.Completed"].Count.Should().Be(1);
            }
        }
コード例 #9
0
 public void It_builds_the_project_before_running()
 {
     var testCommand = new DotnetTestCommand();
     var result = testCommand.Execute($"{_projectFilePath}");
     result.Should().Pass();
 }
        public void It_runs_tests_for_netcoreapp10()
        {
            Setup();

            using (var adapter = new Adapter("TestExecution.GetTestRunnerProcessStartInfo"))
            {
                adapter.Listen();

                var testCommand = new DotnetTestCommand();
                var result = testCommand.Execute($"{_projectFilePath} -f netcoreapp1.0 -o {_netCoreAppOutputPath} --port {adapter.Port} --no-build");
                result.Should().Pass();

                adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
                adapter.Messages["TestExecution.TestRunnerProcessStartInfo"].Count.Should().Be(1);
                adapter.Messages["TestExecution.TestStarted"].Count.Should().Be(4);
                adapter.Messages["TestExecution.TestResult"].Count.Should().Be(4);
                adapter.Messages["TestExecution.Completed"].Count.Should().Be(1);
            }
        }
        public void It_skips_build_when_the_no_build_flag_is_passed_for_netcoreapp10()
        {
            var buildCommand = new BuildCommand(_projectFilePath);
            var result = buildCommand.Execute($"-f netcoreapp1.0 -o {_defaultNetCoreAppOutputPath}");
            result.Should().Pass();

            var testCommand = new DotnetTestCommand();
            result = testCommand.Execute($"{_projectFilePath} -f netcoreapp10 -o {_defaultNetCoreAppOutputPath} --no-build");
            result.Should().Pass();
        }
        public void It_runs_tests_for_all_tfms_if_they_fail()
        {
            var testCommand = new DotnetTestCommand
            {
                Environment =
                {
                    { "DOTNET_TEST_SHOULD_FAIL", "1" }
                }
            };

            var result = testCommand
                .ExecuteWithCapturedOutput($"{_projectFilePath}");

            result.Should().Fail();
            result.StdOut.Should().Contain("Failing in NET451");
            result.StdOut.Should().Contain("Failing in NETCOREAPP1.0");
        }
        public void It_prints_error_when_no_framework_matched()
        {
            var nonExistentFramework = "doesnotexisttfm99.99";
            var testCommand = new DotnetTestCommand();
            var result = testCommand
                .ExecuteWithCapturedOutput($"{_projectFilePath} -f {nonExistentFramework}");

            result.Should().Fail();
            result.StdErr.Should().Contain($"does not support framework");
        }
        public void It_skips_build_when_the_no_build_flag_is_passed_for_net451()
        {
            var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
            var buildCommand = new BuildCommand(_projectFilePath);
            var result = buildCommand.Execute($"-f net451 -r {rid} -o {_defaultNet451OutputPath}");
            result.Should().Pass();

            var testCommand = new DotnetTestCommand();
            result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_defaultNet451OutputPath} --no-build");
            result.Should().Pass();
        }