Open reprogrammer opened 13 years ago
There are several ways to invoke quick assist as part of the test framework:
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor
class. It has methods with quickFix
as the name. Right now, they fail because the pop-up does not appear before the timeout expires. The exception happens inside this method org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor.getProposalTable()
. SWTBotEclipseEditor editor= bot.getBot().editorByTitle(getTestFileFullName()).toTextEditor();
editor.pressShortcut(SWT.CTRL, 0, '1');
My concern is, would this fail when run a mac?
Need to figure out a way to select the first option and then type the right characters and press the Enter Key.
@rajkuma1, @vazexqi: In e42da1a6d0482116ebb06cb14dadd231a9a53e6e, I added the test inlinelocalvariable.T02
to invoke a refactoring via quick assist. This commit is in branch test-quick-assist
. As @rajkuma1 said, such a test throws the following exception.
org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 10000 ms.: Could not find auto complete proposal using matcher ANYTHING at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:408) at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:381) at org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor.waitUntil(SWTBotEclipseEditor.java:760) at org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor.quickfix(SWTBotEclipseEditor.java:124) at edu.illinois.codingspectator.ui.tests.inlinelocalvariable.T02.doExecuteRefactoring(T02.java:35) at edu.illinois.codingspectator.ui.tests.RefactoringTest.shouldExecuteRefactoring(RefactoringTest.java:143) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64) at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117) at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71) at java.lang.Thread.run(Thread.java:662)
Note that my test succeeds to pop up the quick fix menu. But, it fails to retrieve the items on the menu and select a particular menu item.
I checked out the source code of SWTBot and imported all of its projects into my workspace. Then, I commented the following two lines from org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(ICondition, long, long)
.
if (System.currentTimeMillis() > limit)
throw new TimeoutException("Timeout after: " + timeout + " ms.: " + condition.getFailureMessage()); //$NON-NLS-1$ //$NON-NLS-2$
By commenting the above two lines, I effectively disabled the timeout for quick fixes. Having disabled the timeouts, I no longer got the exception but SWTBot got stuck in the while loop in org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(ICondition, long, long)
forever. So, I don't think that this issue is due to a short time out.
I believe using the shortcut key to invoke the quick fix doesn't help either, because you still have to wait for the table in the quick fix menu. But, I didn't try that route.
@vazexqi: Can you check if you can reproduce this problem on Mac?
@rajkuma1, @vazexqi: I suggest that we create a minimal program that demonstrates the problem we're facing with testing quick assist and seek help from the community.
@rajkuma1, @vazexqi: I reported this issue to stackoverflow and the SWTBot forum on 7/10/2011.
@rajkuma1, @vazexqi: I opened Eclipse bug 352277 for this issue on 7/16/2011.
Hi guys. I am trying to test auto completion of EL in JSF and I am facing same issue. Any progress or workarounds on this?
@tremes Have you given the solution proposed at http://stackoverflow.com/a/10600358/130224 a try?
Well I am experimenting with this solution and it works good locally, but I have problems using it in Jenkins environment. Following line snippet always produces "Could not find widget" in Jenkins build:
bot.shells("")
I am wondering why...
@tremes I suggest that you follow up at http://stackoverflow.com/a/10600358/130224. We haven't followed up on this issue for a while.
When a refactoring gets invoked via quick-assist (CTRL+1), we set an attribute in the XML file. We need to write tests to make sure that CodingSpectator records such invocations of refactorings correctly.