title: How to trigger another method or task based on testcase failure or skipped or pass in xctest framework
body: <p>I am writing UI test cases in swift using xctest framework. </p>
  
  <p>I want to trigger another task(such as taking screenshot or ) based on testcase pass or fail or skip. My current code is below</p>
  
  <pre><code>  import Foundation
    import XCTest
  
    class HomePageChromeUITests: XCTestCase {
  
  var pathStr:String = ""
  override func setUp() {
  
      super.setUp()
      continueAfterFailure = false
      self.launchWithUserLoggedIn()
  }
  
  override func tearDown() {
      super.tearDown()
  }
  
  func testHomePageChrome_10385() {
      let app = XCUIApplication()
  
  
      let backButton = app.buttons[AccessibilityIdentifiers.PageEditorBackButton]
      let editButton = app.buttons[AccessibilityIdentifiers.PageEditorEditButton]
  
      XCTAssertTrue(backButton.exists &amp;&amp; backButton.frame.origin.x &lt; editButton.frame.origin.x, "Back button does not exist.---10385")
      XCTAssertTrue(!editButton.exists, "Edit button does not exist.---10385")
  
   }
  }
  </code></pre>
  
  <p>I want to trigger a method whenever testcase fails and pass my failed message there That is "10385".</p>
  
  <p>How can i achieve this. Any help would be appreciated.</p>