So if you want a tool that just gathers methods with the TestAttribute, Visual Studio has that built in. It's the Test Explorer, which examines the assemblies in your solution and digs out tests based on the attributes, then lets you run them. It's available in some versions of VS (I use Professional, which has it); I'm not sure exactly which ones do, though.
Usually apps written for this purpose are the way to go. However, you could scan your assemblies yourself for these attributes. It's not really necessary here -- as I said there are testing tools out here that can do that, and things like VSTS will help you integrate into a deployment process -- but since you mentioned you're new to all of this I'll leave it here as something you may or may not need to use in the future. If nothing else, you can adapt it to something else.
Basically, you can use Reflection to get your assemblies, classes, methods, etc. and you can get the attributes that decorate each of them. You'd do it like this:
[TestClass]
public class AttributeFinder
{
[TestMethod]
public void MyTestMethod()
{
// Do something
}
public static void FindAttributes()
{
var assembly = Assembly.GetAssembly(typeof(AttributeFinder));
var types = assembly.GetTypes();
foreach (var t in types)
{
var typeAttr = t.GetCustomAttribute(typeof(TestClassAttribute));
if (typeAttr != null)
{
// Your class has a TestClass attribute on it!
}
var methods = t.GetMethods();
foreach (var m in methods)
{
var methodAttr = m.GetCustomAttribute(typeof(TestMethodAttribute));
if (methodAttr != null)
{
// This method has the TestMethod attribute!
}
}
}
}
}
Again, there are tools that do this for you automatically, and QHero provided you some links. What I've presented here is the long way around and would require you writing your own tooling, which isn't necessary with the stuff out there. But Reflection is a handy technique to know, and this might be useful to, say, generate a report outside of testing tools that lists your test methods/classes or something.