private void CreateTree(string fileName) { try { _asm = Assembly.LoadFile(fileName); listBoxAssemblies.Items.Add(fileName); List <TestInfo> testInfos = new List <TestInfo>(); foreach (Type t in _asm.GetTypes()) { object[] attrs = t.GetCustomAttributes(typeof(Common.TestSuiteAttribute), true); if (attrs.Length > 0) { if (t.IsSubclassOf(typeof(Common.TestsCollectionBase))) { foreach (MethodInfo mi in t.GetMethods()) { object[] categories = mi.GetCustomAttributes(typeof(Common.CategoryAttribute), true); if (categories.Length > 0) { TestInfo testInfo = new TestInfo(); testInfo.Method = mi; object[] path = mi.GetCustomAttributes(typeof(Common.GroupAttribute), true); if (path.Length > 0) { Common.GroupAttribute groupAttribute = (Common.GroupAttribute)path[0]; testInfo.Group = groupAttribute.Path; } else { testInfo.Group = "Default Group"; } object[] name = mi.GetCustomAttributes(typeof(Common.NameAttribute), true); if (name.Length > 0) { Common.NameAttribute nameAttribute = (Common.NameAttribute)name[0]; testInfo.Name = nameAttribute.Name; } else { testInfo.Name = mi.Name; } _tests.Add(testInfo); testInfos.Add(testInfo); } } } } } foreach (TestInfo testInfo in testInfos.OrderBy(ti => ti.Group).ThenBy(ti => ti.Name)) { TreeNode groupNode = FindGroupNode(testInfo.Group); TreeNode node = groupNode.Nodes.Add(testInfo.Name); node.Tag = testInfo; } } catch (Exception ex) { MessageBox.Show(string.Format("Unable to load assembly: {0}", ex.Message)); } }