public void It_builds_the_project_before_running()
        {
            var testCommand = new DotnetTestCommand();
            var result      = testCommand.Execute($"{_projectFilePath}");

            result.Should().Pass();
        }
Beispiel #2
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();
        }
Beispiel #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();
        }
        //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();
        }
Beispiel #5
0
        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_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();
        }
Beispiel #7
0
        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();
        }
        public void It_runs_tests_for_an_assembly_passed_as_param()
        {
            var publishCommand = new PublishCommand(_projectFilePath);
            var result         = publishCommand.Execute();

            result.Should().Pass();

            var assemblyUnderTestPath = Path.Combine(publishCommand.GetOutputDirectory(true).FullName, publishCommand.GetPortableOutputName());

            var testCommand = new DotnetTestCommand();

            result = testCommand.Execute($"{assemblyUnderTestPath}");
            result.Should().Pass();
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        public void It_discovers_tests_for_the_ProjectWithTestsWithNet46()
        {
            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 net46 -r {rid} -o {_net46OutputPath} --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);
            }
        }
Beispiel #12
0
        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);
            }
        }
Beispiel #13
0
        public void It_runs_tests_for_net451()
        {
            Setup();

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

                var testCommand = new DotnetTestCommand();
                var rid         = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
                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["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 ShouldForwardDotnetRootEnvironmentVariablesIfNotProvided()
        {
            var testAsset = _testAssetsManager.CopyTestAsset(TestAppName)
                            .WithSource()
                            .WithVersionVariables();

            var command = new DotnetTestCommand(Log).WithWorkingDirectory(testAsset.Path);

            command.EnvironmentToRemove.Add("DOTNET_ROOT");
            command.EnvironmentToRemove.Add("DOTNET_ROOT(x86)");
            var result = command.Execute(ConsoleLoggerOutputDetailed);

            if (!TestContext.IsLocalized())
            {
                result.StdOut
                .Should().Contain("Total tests: 1")
                .And.Contain("Passed: 1")
                .And.Contain("Passed TestForwardDotnetRootEnvironmentVariables")
                .And.Contain("VSTEST_WINAPPHOST_");
            }

            result.ExitCode.Should().Be(0);
        }