Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created June 14, 2012 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/2932230 to your computer and use it in GitHub Desktop.
Save einarwh/2932230 to your computer and use it in GitHub Desktop.
Finding tests in a given assembly.
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