-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Touch.Client] Add API to exclude tests based on categories.
The NUnitLite API to create test filters is very rudimentary (either subclass TestFilter, or have NUnitLite create the filter based on an xml string), so we can at least make it easy for consumers to exclude tests based on categories, which we need to be able to do for our tests anyway.
- Loading branch information
1 parent
e6fb7d7
commit dafdf9f
Showing
9 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using NUnit.Framework.Internal; | ||
using NUnit.Framework.Interfaces; | ||
|
||
namespace MonoTouch.NUnit.UI { | ||
class ExcludeCategoryFilter : TestFilter { | ||
public HashSet<string> ExcludedCategories { get; private set; } | ||
|
||
public ExcludeCategoryFilter (IEnumerable<string> categories) | ||
{ | ||
ExcludedCategories = new HashSet<string> (categories); | ||
} | ||
|
||
public override TNode AddToXml (TNode parentNode, bool recursive) | ||
{ | ||
throw new NotImplementedException (); | ||
} | ||
|
||
public override bool Match (ITest test) | ||
{ | ||
var categories = test.Properties ["Category"]; | ||
if (categories != null) { | ||
foreach (string cat in categories) { | ||
if (ExcludedCategories.Contains (cat)) | ||
return false; | ||
} | ||
} | ||
|
||
if (test.Parent != null) | ||
return Match (test.Parent); | ||
|
||
return true; | ||
} | ||
|
||
public override bool Pass (ITest test) | ||
{ | ||
return Match (test); | ||
} | ||
} | ||
} |
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
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