Skip to content

Commit

Permalink
205: getLaunchElementFor with binary class file
Browse files Browse the repository at this point in the history
Task-Url: #205
  • Loading branch information
LorenzoBettini committed Aug 25, 2022
1 parent 624f966 commit ffdbdb5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ public void selectProjectFile(String projectName, String fileName) {
SWTBotTreeItem project = getProject(projectName);
project.select(fileName);
}

public void selectProjectElement(String... path) {
bot.tree().expandNode(path).select();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void runtimeOptionsMatch(Map<String, String> configMap) {
* Runs pit after the given runnable is run and waits for it to finish.
* @param runnable which is executed prior to pit
*/
private void runPitAndWaitForIt(Runnable runnable) {
public void runPitAndWaitForIt(Runnable runnable) {
assertNoErrorsInWorkspace();
// reset Summary result
PitSummary.INSTANCE.resetSummary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ protected static void runProjectTest(final String projectName) throws CoreExcept
new PitclipseSteps().runProjectTest(projectName);
}

protected static void runFreeStyleTest(Runnable runnable) throws CoreException {
new PitclipseSteps().runPitAndWaitForIt(runnable);
}

/**
* Asserts that the only active mutator was the given mutator.
* @param mutators which should be the only active mutator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
public class PitclipseUiRunnerTest extends AbstractPitclipseSWTBotTest {

private static final String TEST_PROJECT = "org.pitest.pitclipse.testprojects.emptyclasses";
private static final String NON_JAVA_PROJECT = "org.pitest.pitclipse.testprojects.nonjava";

private static final String FOO_BAR_PACKAGE = "foo.bar";
private static final String FOO_CLASS = "Foo";
private static final String FOO_TEST_CLASS = "FooTest";

@BeforeClass
public static void setupJavaProject() throws CoreException {
// NON_JAVA_PROJECT contains the folder "binarytests"
// used as an external library from FOO_PROJECT
importTestProject(NON_JAVA_PROJECT);
importTestProject(TEST_PROJECT);
openEditor(FOO_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
openEditor(FOO_TEST_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
Expand Down Expand Up @@ -175,4 +180,19 @@ public void runSingleFieldShowsDialogNoTestsFound() throws CoreException {
PAGES.getRunMenu().runPit();
new NoTestsFoundDialog(bot).assertAppears();
}

@Test
public void runBinaryTest() throws CoreException {
removeMethods(FOO_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
removeMethods(FOO_TEST_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
runFreeStyleTest(() ->
PAGES.getPackageExplorer().selectProjectElement(TEST_PROJECT,
"Referenced Libraries",
"binarytests - org.pitest.pitclipse.testprojects.nonjava",
"(default package)",
"EmptyBinaryTest.class")
);
mutationsAre(Collections.emptyList());
noCoverageReportGenerated();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="lib" path="../org.pitest.pitclipse.testprojects.nonjava/binarytests"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This contains an empty test file in binary shape

0 comments on commit ffdbdb5

Please sign in to comment.