title: How to test a function which throws exception, in Dart?
body: <p>Say I have a function which throws exception:</p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>hello() {
      throw "exception of world";
  }
  </code></pre>
  
  <p>I want to test it, so I write a test:</p>
  
  <pre class="lang-dart prettyprint-override"><code>test("function hello should throw exception", () {
      expect(()=&gt;hello(), throwsA("exception of world"));
  });
  </code></pre>
  
  <p>You can see I didn't call <code>hello()</code> directly, instead, I use <code>()=&gt;hello()</code>.</p>
  
  <p>It works but I wonder if is there any other way to write tests for it?</p>