If all you want your function to do is display a diagnostic message, just modify your call to assert slightly.
a = 1;
b = 2;
assert(a == b, 'Test failed')
If you want your function to do something else there may be a way to do what you want. One possibility would be to use the diagnostic input to the qualification functions/methods. But it would be difficult to give a more informative answer without more information about what you want to do.
[Forgot assert can't have an output argument when I copied and pasted the example. Removing the output.]