void (@NotNull String illegalText) { TextWithMnemonic mnemonic; try { mnemonic = TextWithMnemonic.fromMnemonicText(illegalText); } catch (AssertionError e) { // LOG.error becomes assertion error in test assertTrue(e.getCause() instanceof IllegalArgumentException); assertTrue(e.getMessage().contains("mnemonic")); return; } fail("unexpected: " + mnemonic); }