Community
Participate
Working Groups
Build Identifier: 20100917-0705 I've written up [a GUI test][1] using [SWTBot][2] to test the Extract Method refactoring. I use `editor.selectRange()` to select a statement to extract into a method. But, when I run the unit test, the Extract Method refactoring menu item is disabled. Thus, SWTBot fails to invoke the refactoring. When we change `org.eclipse.jdt.ui.actions.ExtractMethodAction` so that the "Extract Method..." menu item is always enabled, our SWTBot passes. But, SWTBot should let us select the menu item without hacking the `org.eclipse.jdt.ui` plugin. The whole project containing the above unit test is [available at github][3]. I've also reported the problem on [the Eclipse forum for SWTBot][4]. But, we haven't received a solution from the forum. [1]: https://github.com/vazexqi/CodingSpectator/blob/test-using-swtbot/edu.illinois.eclipsewatcher.ui.tests/src/edu/illinois/eclipsewatcher/tests/ExtractMethodTest.java [2]: http://www.eclipse.org/swtbot/ [3]: https://github.com/vazexqi/CodingSpectator/tree/test-using-swtbot/edu.illinois.eclipsewatcher.ui.tests [4]: http://www.eclipse.org/forums/index.php?t=rview&goto=558874&th=175411 Reproducible: Always Steps to Reproduce: SWTBotEclipseEditor editor= bot.editorByTitle(TEST_FILE_NAME + ".java").toTextEditor(); editor.setFocus(); //Select a statement to extract into a method. editor.selectRange(7, 8, 38 - 8); SWTBotMenu refactorMenu= bot.menu("Refactor"); assertTrue(refactorMenu.isEnabled()); SWTBotMenu extractConstantMenuItem= refactorMenu.menu("Extract Method..."); assertTrue(extractConstantMenuItem.isEnabled()); //This assertion fails.