         case .unknown:
             state = .unknown
         }
+        results = test.activities?.map { JUnit.TestResult(activity: $0) } ?? []
+    }
+}
+
+extension JUnit.TestResult {
+    init(activity: Activity) {
+        title = activity.title
+        if activity.type == .assertionFailure {
+            state = .failed
+        } else {
+            state = .unknown
+        }
     }
 }
 

        var name: String
        var time: TimeInterval
        var state: State
    }
}


        var xml = "    <testcase classname='\(classname)' name='\(name)' time='\(time)'"
        if state == .failed {
            xml += ">\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 ""
        }
    }
}

