-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for netcoreapp1.1 #270
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eccabab
Multi-targetted xunit+mstset proejcts to netcoreapp1.1
3ef41c9
fixed project load issue.
1443bc5
Added acceptance test for netcoreap1.1
c1575db
Merge branch 'master' into netcoreap11
harshjain2 17146f4
Ignored Parallel tests as they are failing.
7eddffc
Ignore Parallel test as it is failing.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesomeness!