title: How do I get the returning value of a function that can throw that I'm testing with XCTAssertNoThrow(...)
body: <p>I want to get the return value of a function that I'm testing for a subsequent test. The function if defined like this:</p>
  
  <p><code>func apple(banana: Banana) throws -&gt; Cherry { ... }</code></p>
  
  <p>I can test that it throws when it should:</p>
  
  <p><code>XCTAssertThrowsError(try apple(banana: badBanana), "Didn't throw")</code></p>
  
  <p>I can test it doesn't throw when it shouldn't:</p>
  
  <p><code>XCTAssertNoThrow(try apple(banana: goodBanana), "Did throw")</code></p>
  
  <p>I was hoping to do this:</p>
  
  <p><code>XCTAssertNoThrow(let cherry = try apple(banana: goodBanana), "Did throw")</code></p>
  
  <p>and then check <code>cherry</code> is what I would expect, but I get the following error: <code>Consecutive statements on a line must be separated by ';'...</code></p>
  
  <p>How can I get the returned value (an object of type <code>Cherry</code> in this case) from the <code>XCTAssertNoThrow</code> test? Or is there a better approach that I'm missing?</p>
  
  <p>Many thanks</p>