void () { boolean thrownExpectedException = false; try { doTest(); } catch (CommonRefactoringUtil.RefactoringErrorHintException e) { if (e.getMessage().equals("Cannot perform refactoring using the selected elements")) { thrownExpectedException = true; } } assertTrue(thrownExpectedException); }