Created
June 14, 2012 19:01
-
-
Save einarwh/2932230 to your computer and use it in GitHub Desktop.
Finding tests in a given assembly.
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
namespace Mjunit | |
{ | |
public class TestFinder | |
{ | |
public ArrayList FindTests(Assembly assembly) | |
{ | |
var types = assembly.GetTypes(); | |
var fixtures = GetTestFixtures(types); | |
var groups = GetTestGroups(fixtures); | |
return groups; | |
} | |
private ArrayList GetTestFixtures(Type[] types) | |
{ | |
var result = new ArrayList(); | |
for (int i = 0; i < types.Length; i++) | |
{ | |
var t = types[i]; | |
if (t.IsSubclassOf(typeof(Fixture))) | |
{ | |
result.Add(t); | |
} | |
} | |
return result; | |
} | |
private ArrayList GetTestGroups(ArrayList fixtures) | |
{ | |
var result = new ArrayList(); | |
foreach (Type t in fixtures) | |
{ | |
var g = new TestGroup(t); | |
if (g.NumberOfTests > 0) | |
{ | |
result.Add(g); | |
} | |
} | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment