Skip to content

Commit

Permalink
Merge pull request #185 from pitest/Run_config_bug
Browse files Browse the repository at this point in the history
Fix bug, creating run config, if one exists
  • Loading branch information
LorenzoBettini authored Jul 27, 2022
2 parents 47f341c + 87bab65 commit e16eaf5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ private void showNoTestsFoundDialog() {
private void performLaunch(IJavaElement element, String mode) throws InterruptedException, CoreException {
ILaunchConfigurationWorkingCopy tmp = createLaunchConfiguration(element);
Optional<ILaunchConfiguration> existingConfig = findExistingLaunchConfiguration(tmp);
ILaunchConfiguration config = existingConfig.orElse(tmp.doSave());
ILaunchConfiguration config;
if (existingConfig.isPresent()) {
config = existingConfig.get();
} else {
config = tmp.doSave();
}
DebugUITools.launch(config, mode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import java.util.List;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.pitest.pitclipse.core.Mutators;
import org.pitest.pitclipse.runner.PitOptions;
import org.pitest.pitclipse.ui.swtbot.PitOptionsNotifier;
Expand Down Expand Up @@ -54,8 +52,6 @@ public void runPit() {
SWTBotMenu runAsMenu = menuHelper.findWorkbenchMenu(bot, RUN).menu(RUN_AS);
menuHelper.findMenu(runAsMenu, PIT_MUTATION_TEST)
.click();

ensureSelectTestConfigurationDialogIsClosed();
}

public void runPitWithConfiguration(String configurationName) {
Expand All @@ -64,27 +60,6 @@ public void runPitWithConfiguration(String configurationName) {
}
}

/**
* The 'Select a Test Configuration' dialog only appears when Pit has been
* launched at least once. If it is not found then PIT has been launched
* directly during the click on 'Run As > PIT Mutation Test' so everything's
* alright.
*
* This is a fast way for closing the dialog by iterating over the shells, instead
* of searching for such a shell swallowing {@link WidgetNotFoundException}.
*/
private void ensureSelectTestConfigurationDialogIsClosed() {
SWTBotShell[] shells = bot.shells();
for (SWTBotShell shell : shells) {
if ("Select a Test Configuration".equals(shell.getText())) {
shell.bot()
.button("OK")
.click();
return;
}
}
}

public List<PitRunConfiguration> runConfigurations() {
SWTBotMenuHelper menuHelper = new SWTBotMenuHelper();
menuHelper.findMenu(menuHelper.findWorkbenchMenu(bot, RUN), RUN_CONFIGURATIONS).click();
Expand Down

0 comments on commit e16eaf5

Please sign in to comment.