Search code examples
muleanypoint-studio

Assert exception thrown in MUnit, Mulesoft


Is there a way to assert that a flow reference threw an exception in Mulesoft? Searching Google and the documentation isn't turning up anything.

Basically I'm testing a subflow that throws a NotFound exception if a certain item exists, but MUnit fails when it receives the error, even though it's expected.

I know I could mock my validator and have it return specific data which I then check for, but I was hoping there's something native that can do this that's less hacky.


Solution

  • I think what you're looking for is the 'expectException' attribute on the test itself. HTH.