-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for netcoreapp1.1 (#270)
* Multi-targetted xunit+mstset proejcts to netcoreapp1.1 * fixed project load issue. * Added acceptance test for netcoreap1.1 * Ignored Parallel tests as they are failing. * Ignore Parallel test as it is failing.
- Loading branch information
1 parent
7394dfb
commit 9a04658
Showing
42 changed files
with
322 additions
and
646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
test/Microsoft.TestPlatform.AcceptanceTests/Extension/CustomDataTestMethodAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.TestPlatform.AcceptanceTests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
/// <summary> | ||
/// The custom data test method attribute. | ||
/// </summary> | ||
public class CustomDataTestMethodAttribute : TestMethodAttribute | ||
{ | ||
/// <summary> | ||
/// Find all data rows and execute. | ||
/// </summary> | ||
/// <param name="testMethod"> | ||
/// The test Method. | ||
/// </param> | ||
/// <returns> | ||
/// The <see cref="TestResult[]"/>. | ||
/// </returns> | ||
public override TestResult[] Execute(ITestMethod testMethod) | ||
{ | ||
List<DataRowAttribute> dataRows = new List<DataRowAttribute>(); | ||
|
||
var net46Rows = testMethod.GetAttributes<NET46TargetFramework>(false); | ||
if (net46Rows != null && net46Rows.Length > 0 && net46Rows[0].DataRows.Count > 0) | ||
{ | ||
dataRows.AddRange(net46Rows[0].DataRows); | ||
} | ||
|
||
var netcoreappRows = testMethod.GetAttributes<NETCORETargetFramework>(false); | ||
if (netcoreappRows != null && netcoreappRows.Length > 0 && netcoreappRows[0].DataRows.Count > 0) | ||
{ | ||
dataRows.AddRange(netcoreappRows[0].DataRows); | ||
} | ||
|
||
if (dataRows.Count == 0) | ||
{ | ||
return new TestResult[] { new TestResult() { Outcome = UnitTestOutcome.Failed, TestFailureException = new Exception(FrameworkMessages.NoDataRow) } }; | ||
} | ||
|
||
return RunDataDrivenTest(testMethod, dataRows.ToArray()); | ||
} | ||
|
||
/// <summary> | ||
/// Run data driven test method. | ||
/// </summary> | ||
/// <param name="testMethod"> Test method to execute. </param> | ||
/// <param name="dataRows"> Data Row. </param> | ||
/// <returns> Results of execution. </returns> | ||
internal static TestResult[] RunDataDrivenTest(ITestMethod testMethod, DataRowAttribute[] dataRows) | ||
{ | ||
List<TestResult> results = new List<TestResult>(); | ||
|
||
foreach (var dataRow in dataRows) | ||
{ | ||
TestResult result = testMethod.Invoke(dataRow.Data); | ||
|
||
if (!string.IsNullOrEmpty(dataRow.DisplayName)) | ||
{ | ||
result.DisplayName = dataRow.DisplayName; | ||
} | ||
else | ||
{ | ||
result.DisplayName = string.Format(CultureInfo.CurrentCulture, FrameworkMessages.DataDrivenResultDisplayName, testMethod.TestMethodName, string.Join(",", dataRow.Data)); | ||
} | ||
|
||
results.Add(result); | ||
} | ||
|
||
return results.ToArray(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The attribute defining runner framework, target framework and target runtime for net46. | ||
/// </summary> | ||
public class NET46TargetFramework : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NET46TargetFramework"/> class. | ||
/// </summary> | ||
public NET46TargetFramework() | ||
{ | ||
this.DataRows = new List<DataRowAttribute>(2); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.CoreRunnerFramework, AcceptanceTestBase.DesktopTargetFramework, AcceptanceTestBase.CoreRunnerTargetRuntime)); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.DesktopRunnerFramework, AcceptanceTestBase.DesktopTargetFramework, AcceptanceTestBase.DesktopRunnerTargetRuntime)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the data rows. | ||
/// </summary> | ||
public List<DataRowAttribute> DataRows { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// The attribute defining runner framework, target framework and target runtime for netcoreapp1.* | ||
/// </summary> | ||
public class NETCORETargetFramework : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NETCORETargetFramework"/> class. | ||
/// </summary> | ||
public NETCORETargetFramework() | ||
{ | ||
this.DataRows = new List<DataRowAttribute>(4); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.CoreRunnerFramework, AcceptanceTestBase.CoreTargetFramework, AcceptanceTestBase.CoreRunnerTargetRuntime)); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.DesktopRunnerFramework, AcceptanceTestBase.CoreTargetFramework, AcceptanceTestBase.DesktopRunnerTargetRuntime)); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.CoreRunnerFramework, AcceptanceTestBase.Core11TargetFramework, AcceptanceTestBase.CoreRunnerTargetRuntime)); | ||
this.DataRows.Add(new DataRowAttribute(AcceptanceTestBase.DesktopRunnerFramework, AcceptanceTestBase.Core11TargetFramework, AcceptanceTestBase.DesktopRunnerTargetRuntime)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the data rows. | ||
/// </summary> | ||
public List<DataRowAttribute> DataRows { get; set; } | ||
} | ||
} |
Oops, something went wrong.