Testing framework bug (wrong textAfter value in doTextTest())

========================================================

========================================================
but was: [junit] junit.framework.ComparisonFailure: Text mismatch expected:<> but was: [junit] at com.intellij.testFramework.LightCodeInsightTestCase.checkResultByText(LightCodeInsightTestCase.java:104) [junit] at com.intellij.testFramework.EditorActionTestCase.doTextTest(EditorActionTestCase.java:7) [junit] at com.intellij.testFramework.EditorActionTestCase.doTextTest(EditorActionTestCase.java:17) [junit] at Test.testDoTextTest(Test.java:20) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [junit] at com.intellij.testFramework.LightCodeInsightTestCase.a(LightCodeInsightTestCase.java:89) [junit] at com.intellij.testFramework.LightCodeInsightTestCase$2.run(LightCodeInsightTestCase.java) [junit] at com.intellij.openapi.command.b.b.executeCommand(b.java:26) [junit] at com.intellij.testFramework.LightCodeInsightTestCase$1.run(LightCodeInsightTestCase.java:2) [junit] at com.intellij.openapi.application.a.d.runWriteAction(d.java:262) [junit] at com.intellij.testFramework.LightCodeInsightTestCase.runTest(LightCodeInsightTestCase.java:31) [junit] at com.intellij.testFramework.LightIdeaTestCase.d(LightIdeaTestCase.java:23) [junit] at com.intellij.testFramework.LightIdeaTestCase.a(LightIdeaTestCase.java:4) [junit] at com.intellij.testFramework.LightIdeaTestCase$2.run(LightIdeaTestCase.java) [junit] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:171) [junit] at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) [junit] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) [junit] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) [junit] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) [junit] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) [junit] at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) ]]>
========================================================

评论操作 固定链接

I have a workaround. If anyone else encounter this before it's fixed, let me know - I'll post the code.


Timur

0
评论操作 固定链接

Psi commit? Yeah, I think this should be done automatically.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Timur Zambalayev" <no_mail@jetbrains.com> wrote in message
news:10238916.1061602839943.JavaMail.itn@is.intellij.net...

I have a workaround. If anyone else encounter this before it's fixed, let

me know - I'll post the code.
>
>

Timur

>


0
评论操作 固定链接

Psi commit? Yeah, I think this should be done
automatically.


No. I didn't think about it. This way you'll have to change the tested code.

Here's my workaround:

",
                "",
                "",
            };
            for (int i = 0; i < configStrings.length; i++) {
                expectedText = expectedText.replaceFirst(configStrings+, "");
            }
            assertEquals(expectedText, getEditor().getDocument().getText());
        }
]]>

0
评论操作 固定链接

It's just another way to fix the original problem since checkResultByText
(called from doTextTest) uses text from PsiFile to compare while the
document has been actually changed. In 907 they gonna get in sync prior to
comparing.

--

Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Timur Zambalayev" <no_mail@jetbrains.com> wrote in message
news:25169816.1061821628497.JavaMail.itn@is.intellij.net...

Psi commit? Yeah, I think this should be done
automatically.

>

No. I didn't think about it. This way you'll have to change the tested

code.
>

Here's my workaround:

>

         try {
>             super.doTextTest(fileName, textBefore, textAfter);
>         } catch (ComparisonFailure e) {
>             if (e.getMessage().indexOf("Text mismatch") == -1) {
>                 throw e;
>             }
>             String expectedText = textAfter;
>             String[] configStrings = {
>                 "",
>                 "",
>                 "",
>             };
>             for (int i = 0; i < configStrings.length; i++) {
>                 expectedText = expectedText.replaceFirst(configStrings+,
"");
>             }
>             assertEquals(expectedText,
getEditor().getDocument().getText());
>         }
> ]]>



0

请先登录再写评论。