示例#1
0
        public void TestsFromAGivenContainerShouldRunWithExpectedOutput()
        {
            var testAppName = "VSTestCore";
            var testRoot    = TestAssets.Get(testAppName)
                              .CreateInstance()
                              .WithSourceFiles()
                              .WithRestoreFiles()
                              .Root;

            var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";

            new BuildCommand()
            .WithWorkingDirectory(testRoot)
            .Execute()
            .Should().Pass();

            var outputDll = testRoot
                            .GetDirectory("bin", configuration, "netcoreapp2.0")
                            .GetFile($"{testAppName}.dll");

            var argsForVstest = $"\"{outputDll.FullName}\" --logger:console;verbosity=normal";

            // Call vstest
            var result = new VSTestCommand().ExecuteWithCapturedOutput(argsForVstest);

            result.StdOut
            .Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.")
            .And.Contain("Passed   TestNamespace.VSTestTests.VSTestPassTest")
            .And.Contain("Failed   TestNamespace.VSTestTests.VSTestFailTest");
            result.ExitCode.Should().Be(1);
        }
示例#2
0
        public void TestsFromAGivenContainerShouldRunWithExpectedOutput()
        {
            // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
            string       testAppName  = "VSTestDotNetCoreProject";
            TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName).WithLockFiles();

            string testProjectDirectory = testInstance.TestRoot;

            // Build project DotNetCoreTestProject
            new Build3Command()
            .WithWorkingDirectory(testProjectDirectory)
            .Execute()
            .Should()
            .Pass();

            // Prepare args to send vstest
            string configuration   = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
            string testAdapterPath = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0");
            string outputDll       = Path.Combine(testAdapterPath, $"{testAppName}.dll");
            string argsForVstest   = string.Concat("\"", outputDll, "\"", " --TestAdapterPath:", "\"", testAdapterPath, "\"");

            // Call vstest
            CommandResult result = new VSTestCommand().ExecuteWithCapturedOutput(argsForVstest);

            // Verify
            result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
            result.StdOut.Should().Contain("Passed   TestNamespace.VSTestTests.VSTestPassTest");
            result.StdOut.Should().Contain("Failed   TestNamespace.VSTestTests.VSTestFailTest");
        }