void () { final Module a = ModuleManager.getInstance(getProject()).findModuleByName("A"); final Module b = ModuleManager.getInstance(getProject()).findModuleByName("B"); ModuleRootModificationUtil.addDependency(a, b); removeModule(); try { doTest("B/src/y/AddDependency.java", true); fail("user should have been warned"); } catch (RuntimeException e) { final String expected = "Adding dependency on module '" + a.getName() + "'" + " will introduce circular dependency between modules '" + a.getName() + "' and '" + b.getName() + "'.\n" + "Add dependency anyway?"; String message = e.getMessage(); assertEquals(expected, message); } }