Skip to content

[tests] Add category support to the new NUnit runner, and a category to the DotNetInterfacesShouldEqualJavaInterfaces test #1963

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

Merged
merged 6 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Mono.Android/Test/System.Net/NetworkInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool HardwareAddressesAreEqual (byte[] one, byte[] two)
}
}

[Test]
[Test, Category("NetworkInterfaces")]
public void DotNetInterfacesShouldEqualJavaInterfaces ()
{
List <InterfaceInfo> dotnetInterfaces = GetInfos (MNetworkInterface.GetAllNetworkInterfaces ());
Expand Down
11 changes: 11 additions & 0 deletions tests/TestRunner.Core/TestInstrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ protected virtual Assembly LoadTestAssembly (string filePath)
return Assembly.LoadFrom (filePath);
}

protected Dictionary<string, string> GetStringExtrasFromBundle ()
{
var filtersFromBundle = new Dictionary<string, string> ();
foreach (var key in arguments.KeySet ()) {
string value = arguments.GetString (key);
if (!string.IsNullOrEmpty (value))
filtersFromBundle.Add (key, value);
}
return filtersFromBundle;
}

protected virtual void ConfigureFilters (TRunner runner)
{}

Expand Down
17 changes: 17 additions & 0 deletions tests/TestRunner.NUnit/NUnitTestInstrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ protected override NUnitTestRunner CreateRunner (LogWriter logger, Bundle bundle
};
}

IEnumerable<string> GetFilterValuesFromExtras (string key)
{
Dictionary<string, string> extras = GetStringExtrasFromBundle ();
if (extras.ContainsKey (key)) {
string filterValue = extras [key];
if (!string.IsNullOrEmpty (filterValue))
return filterValue.Split (':');
}
return null;
}

protected override void ConfigureFilters (NUnitTestRunner runner)
{
base.ConfigureFilters(runner);
Expand All @@ -54,9 +65,15 @@ protected override void ConfigureFilters (NUnitTestRunner runner)
Log.Info (LogTag, "Configuring test categories to include:");
ChainCategoryFilter (IncludedCategories, false, ref filter);

Log.Info (LogTag, "Configuring test categories to include from extras:");
ChainCategoryFilter (GetFilterValuesFromExtras ("include"), false, ref filter);

Log.Info (LogTag, "Configuring test categories to exclude:");
ChainCategoryFilter (ExcludedCategories, true, ref filter);

Log.Info(LogTag, "Configuring test categories to exclude from extras:");
ChainCategoryFilter (GetFilterValuesFromExtras ("exclude"), true, ref filter);

Log.Info (LogTag, "Configuring tests to exclude (by name):");
ChainTestNameFilter (ExcludedTestNames?.ToArray (), ref filter);

Expand Down