Skip to content

Commit

Permalink
205: test when two elements are selected
Browse files Browse the repository at this point in the history
Task-Url: #205
  • Loading branch information
LorenzoBettini committed Aug 25, 2022
1 parent d311a2c commit a2d2793
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright 2022 Lorenzo Bettini and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************/

package org.pitest.pitclipse.ui.behaviours.pageobjects;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;

public class NoTestsFoundDialog {

private final SWTWorkbenchBot bot;

public NoTestsFoundDialog(SWTWorkbenchBot bot) {
this.bot = bot;
}

public void assertAppears() {
SWTBotShell shell = bot.shell("Pitclipse");
shell.activate();
bot.label("No tests found");
bot.button("OK").click();

// Ensure the project is fully created before moving on
bot.waitUntil(Conditions.shellCloses(shell));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public void selectClass(String className, String packageName, String projectName
selectAndExpand(classItem);
}

public void selectFiles(String projectName, String packageName, String... fileNames) {
SWTBotTreeItem project = getProject(projectName);
SWTBotTreeItem pkg = selectAndExpand(getPackageFromProject(project, packageName));
pkg.select(fileNames);
}

public boolean doesClassExistInProject(String className, String packageName, String projectName) {
SWTBotTreeItem project = getProject(projectName);
SWTBotTreeItem pkg = selectAndExpand(getPackageFromProject(project, packageName));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.pitest.pitclipse.ui.tests;

import static org.pitest.pitclipse.ui.behaviours.pageobjects.PageObjects.PAGES;

import java.util.Collections;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.pitest.pitclipse.ui.behaviours.pageobjects.NoTestsFoundDialog;

/**
* @author Lorenzo Bettini
Expand Down Expand Up @@ -124,4 +127,11 @@ public void runPitAtPackageAndPackageRootAndProjectLevel() throws CoreException
coverageReportGenerated(1, 100, 100, 2, 2);
}

@Test
public void runPitOnTwoSelectedElementsShowDialogNoTestsFound() throws CoreException {
PAGES.getPackageExplorer().selectFiles(TEST_PROJECT, FOO_BAR_PACKAGE,
FOO_CLASS + ".java", FOO_TEST_CLASS + ".java");
PAGES.getRunMenu().runPit();
new NoTestsFoundDialog(bot).assertAppears();
}
}

0 comments on commit a2d2793

Please sign in to comment.