2016-09-19 23:29:26 +05:30
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.VSTest.Tests
|
|
|
|
|
{
|
2016-10-04 00:17:35 +05:30
|
|
|
|
public class VSTestTests : TestBase
|
2016-09-19 23:29:26 +05:30
|
|
|
|
{
|
2016-11-01 16:18:33 +05:30
|
|
|
|
[Fact]
|
2016-09-19 23:29:26 +05:30
|
|
|
|
public void TestsFromAGivenContainerShouldRunWithExpectedOutput()
|
|
|
|
|
{
|
2017-05-02 21:30:51 -07:00
|
|
|
|
var testAppName = "VSTestCore";
|
2016-12-13 14:15:35 -08:00
|
|
|
|
var testRoot = TestAssets.Get(testAppName)
|
|
|
|
|
.CreateInstance()
|
2017-01-04 22:13:19 -08:00
|
|
|
|
.WithSourceFiles()
|
2016-12-13 14:15:35 -08:00
|
|
|
|
.WithRestoreFiles()
|
|
|
|
|
.Root;
|
2016-09-19 23:29:26 +05:30
|
|
|
|
|
2016-12-13 14:15:35 -08:00
|
|
|
|
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
2016-09-19 23:29:26 +05:30
|
|
|
|
|
2017-01-04 22:13:19 -08:00
|
|
|
|
new BuildCommand()
|
|
|
|
|
.WithWorkingDirectory(testRoot)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should().Pass();
|
|
|
|
|
|
2016-12-13 14:15:35 -08:00
|
|
|
|
var outputDll = testRoot
|
2017-08-18 15:36:01 -07:00
|
|
|
|
.GetDirectory("bin", configuration, "netcoreapp2.1")
|
2016-12-13 14:15:35 -08:00
|
|
|
|
.GetFile($"{testAppName}.dll");
|
2016-10-04 00:17:35 +05:30
|
|
|
|
|
2017-03-16 23:15:45 -07:00
|
|
|
|
var argsForVstest = $"\"{outputDll.FullName}\" --logger:console;verbosity=normal";
|
2016-11-01 17:17:45 +05:30
|
|
|
|
|
|
|
|
|
// Call vstest
|
2016-12-16 15:39:52 +05:30
|
|
|
|
var result = new VSTestCommand().ExecuteWithCapturedOutput(argsForVstest);
|
2017-06-12 18:32:31 -07:00
|
|
|
|
if (!DotnetUnderTest.IsLocalized())
|
|
|
|
|
{
|
|
|
|
|
result.StdOut
|
|
|
|
|
.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.")
|
2017-10-11 12:21:59 +05:30
|
|
|
|
.And.Contain("Passed VSTestPassTest")
|
|
|
|
|
.And.Contain("Failed VSTestFailTest");
|
2017-06-12 18:32:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-16 15:39:52 +05:30
|
|
|
|
result.ExitCode.Should().Be(1);
|
2016-09-19 23:29:26 +05:30
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|