Skip to content

Commit

Permalink
Added wait condition to PitResultNotifier
Browse files Browse the repository at this point in the history
Also removed checks in PitclipseUiRunnerTest for coverage generatetd,
because there is no report generatetd anymore
  • Loading branch information
JKutscha committed Jul 18, 2021
1 parent d71a67e commit 7e9894f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

import java.io.IOException;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.pitest.pitclipse.core.extension.point.ResultNotifier;
import org.pitest.pitclipse.runner.PitResults;
import org.pitest.pitclipse.ui.swtbot.ResultsParser.Summary;
Expand All @@ -27,44 +31,71 @@ public enum PitSummary {
INSTANCE;

private Summary summary;
private SWTWorkbenchBot bot;

/**
* @return covered classes or 0 if no summary is present
*/
public int getClasses() {
if (summary != null) {
return summary.getClasses();
}
return 0;
bot.waitUntil(new ICondition() {
public boolean test() throws Exception {
return PitSummary.INSTANCE.getSummary() != null;
}

public void init(SWTBot bot) {
// Intentional empty
}

public String getFailureMessage() {
return "No summary set.";
}
}, SWTBotPreferences.TIMEOUT);
return summary.getClasses();
}

/**
* @return code coverage or 100 if no summary is present
*/
public double getCodeCoverage() {
if (summary != null) {
return summary.getCodeCoverage();
}
return 100;
bot.waitUntil(new ICondition() {
public boolean test() throws Exception {
return PitSummary.INSTANCE.getSummary() != null;
}

public void init(SWTBot bot) {
// Intentional empty
}

public String getFailureMessage() {
return "No summary set.";
}
}, SWTBotPreferences.TIMEOUT);
return summary.getCodeCoverage();
}

/**
* @return mutation coverage or 100 if no summary is present
*/
public double getMutationCoverage() {
if (summary != null) {
return summary.getMutationCoverage();
}
return 100;
bot.waitUntil(new ICondition() {
public boolean test() throws Exception {
return PitSummary.INSTANCE.getSummary() != null;
}

public void init(SWTBot bot) {
// Intentional empty
}

public String getFailureMessage() {
return "No summary set.";
}
}, SWTBotPreferences.TIMEOUT);
return summary.getMutationCoverage();
}

public void reset() {
bot = new SWTWorkbenchBot();
summary = null;
}

void setSummary(Summary summary) {
this.summary = summary;
}

Summary getSummary() {
return summary;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void emptyClassAndEmptyTest() throws CoreException {
runTest(FOO_TEST_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
consoleContains(0, 0, 100, 0, 0);
mutationsAre(Collections.emptyList());
coverageReportGenerated(0, 100, 100);
}

@Test
Expand All @@ -48,7 +47,6 @@ public void emptyClassAndEmptyTestMethod() throws CoreException {
runTest(FOO_TEST_CLASS, FOO_BAR_PACKAGE, TEST_PROJECT);
consoleContains(0, 0, 100, 0, 0);
mutationsAre(Collections.emptyList());
coverageReportGenerated(0, 100, 100);
}

@Test
Expand Down

0 comments on commit 7e9894f

Please sign in to comment.