         var xml = "    <testcase classname='\(classname)' name='\(name)' time='\(time)'"
         if state == .failed {
             xml += ">\n"
-            xml += "      <failure/>\n"
+            results.forEach { (result) in
+                xml += result.xmlString
+            }
             xml += "    </testcase>\n"
         } else {
             xml += "/>\n"
         }
         return xml
+    }
+}
+
+extension JUnit.TestResult: XMLRepresentable {
+    var xmlString: String {
+        switch state {
+        case .failed:
+            // TODO: The title should probably be XML escaped
+            return "      <failure>\(title)</failure>\n"
+        default:
+            return ""
+        }
     }
 }
 

        case .unknown:
            state = .unknown
        }
    }
}


        var name: String
        var time: TimeInterval
        var state: State
        var results: [TestResult]
    }
    struct TestResult {
        enum State {
            case unknown
            case failed
        }
        var title: String
        var state: State
    }
}

