2016-09-19 17:59:26 +00:00
|
|
|
|
// 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-03 18:47:35 +00:00
|
|
|
|
public class VSTestTests : TestBase
|
2016-09-19 17:59:26 +00:00
|
|
|
|
{
|
2016-11-01 10:48:33 +00:00
|
|
|
|
[Fact]
|
2016-09-19 17:59:26 +00:00
|
|
|
|
public void TestsFromAGivenContainerShouldRunWithExpectedOutput()
|
|
|
|
|
{
|
2016-12-13 22:15:35 +00:00
|
|
|
|
var testAppName = "VSTestDotNetCore";
|
|
|
|
|
var testRoot = TestAssets.Get(testAppName)
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithRestoreFiles()
|
|
|
|
|
.WithBuildFiles()
|
|
|
|
|
.Root;
|
2016-09-19 17:59:26 +00:00
|
|
|
|
|
2016-12-13 22:15:35 +00:00
|
|
|
|
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
2016-09-19 17:59:26 +00:00
|
|
|
|
|
2016-12-13 22:15:35 +00:00
|
|
|
|
var outputDll = testRoot
|
|
|
|
|
.GetDirectory("bin", configuration, "netcoreapp1.0")
|
|
|
|
|
.GetFile($"{testAppName}.dll");
|
2016-10-03 18:47:35 +00:00
|
|
|
|
|
2016-12-13 22:15:35 +00:00
|
|
|
|
var argsForVstest = $"\"{outputDll.FullName}\"";
|
2016-11-01 11:47:45 +00:00
|
|
|
|
|
|
|
|
|
// Call vstest
|
2016-12-16 10:09:52 +00:00
|
|
|
|
var result = new VSTestCommand().ExecuteWithCapturedOutput(argsForVstest);
|
|
|
|
|
result.StdOut
|
2016-12-13 22:15:35 +00:00
|
|
|
|
.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.")
|
2016-12-16 10:09:52 +00:00
|
|
|
|
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTest")
|
|
|
|
|
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
|
|
|
|
|
result.ExitCode.Should().Be(1);
|
2016-09-19 17:59:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|