/// <summary> /// Adds the test execution time to the XML node. /// </summary> /// <param name="testNode">The XML node.</param> protected void AddTime(XmlNode testNode) { XmlUtility.AddAttribute(testNode, "time", ExecutionTime.ToString("0.000", CultureInfo.InvariantCulture)); }
public EnumerateTests(Executor executor, object _handler) { ExecutorCallback handler = ExecutorCallback.Wrap(_handler); XmlDocument doc = new XmlDocument(); doc.LoadXml("<dummy/>"); XmlNode assemblyNode = XmlUtility.AddElement(doc.ChildNodes[0], "assembly"); XmlUtility.AddAttribute(assemblyNode, "name", executor.assemblyFilename); foreach (Type type in executor.assembly.GetExportedTypes()) { ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type); if (testClassCommand != null) { string typeName = type.FullName; XmlNode classNode = XmlUtility.AddElement(assemblyNode, "class"); XmlUtility.AddAttribute(classNode, "name", typeName); foreach (IMethodInfo method in testClassCommand.EnumerateTestMethods()) { string methodName = method.Name; string displayName = null; foreach (IAttributeInfo attr in method.GetCustomAttributes(typeof(FactAttribute))) { displayName = attr.GetPropertyValue <string>("Name"); } XmlNode methodNode = XmlUtility.AddElement(classNode, "method"); XmlUtility.AddAttribute(methodNode, "name", displayName ?? typeName + "." + methodName); XmlUtility.AddAttribute(methodNode, "type", typeName); XmlUtility.AddAttribute(methodNode, "method", methodName); string skipReason = MethodUtility.GetSkipReason(method); if (skipReason != null) { XmlUtility.AddAttribute(methodNode, "skip", skipReason); } var traits = MethodUtility.GetTraits(method); if (traits.Count > 0) { XmlNode traitsNode = XmlUtility.AddElement(methodNode, "traits"); traits.ForEach((name, value) => { XmlNode traitNode = XmlUtility.AddElement(traitsNode, "trait"); XmlUtility.AddAttribute(traitNode, "name", name); XmlUtility.AddAttribute(traitNode, "value", value); }); } } } } handler.Notify(assemblyNode.OuterXml); }