From bca1ff64b2d17e0b07cdf048da68f9cf4cd40eb1 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 4 Feb 2011 17:01:51 +0100 Subject: [PATCH] Better diagnostics --- .../impl/CodeInsightTestFixtureImpl.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 1c94c54fcc2a..1be728e94d84 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -127,11 +127,18 @@ import java.util.*; /** * @author Dmitry Avdeev */ -@SuppressWarnings({"TestMethodWithIncorrectSignature"}) +@SuppressWarnings({"TestMethodWithIncorrectSignature", "JUnitTestCaseWithNoTests", "JUnitTestClassNamingConvention"}) public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsightTestFixture { @NonNls private static final String PROFILE = "Configurable"; + private static final Function INTENTION_NAME_FUN = new Function() { + @Override + public String fun(final IntentionAction intentionAction) { + return "\"" + intentionAction.getText() + "\""; + } + }; + private PsiManagerImpl myPsiManager; private PsiFile myFile; private Editor myEditor; @@ -480,13 +487,11 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public IntentionAction findSingleIntention(@NotNull final String hint) { final List list = filterAvailableIntentions(hint); - if (list.size() != 1) { - Assert.fail(StringUtil.join(getAvailableIntentions(), new Function() { - @Override - public String fun(final IntentionAction intentionAction) { - return intentionAction.getText(); - } - }, ", ")); + if (list.size() == 0) { + Assert.fail("\"" + hint + "\" not in [" + StringUtil.join(getAvailableIntentions(), INTENTION_NAME_FUN, ", ") + "]"); + } + else if (list.size() > 1) { + Assert.fail("Too many intention found for \"" + hint + "\": [" + StringUtil.join(list, INTENTION_NAME_FUN, ", ") + "]"); } return UsefulTestCase.assertOneElement(list); }