Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e90a80e

Browse filesBrowse files
fix counters for incomplete tests (e.g. when event could not be processed)
1 parent bec7a40 commit e90a80e
Copy full SHA for e90a80e

File tree

1 file changed

+59
-37
lines changed
Filter options

1 file changed

+59
-37
lines changed

‎sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.java

Copy file name to clipboardExpand all lines: sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.java
+59-37Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,52 @@ private void runCodeCoverage(boolean selectedOnly) {
709709
reporter.showParameterWindow();
710710
}
711711

712+
private void fixCountersAndUpdate() {
713+
// fix incompleteTests
714+
List<Test> incompleteTests = currentRun.getTests().values().stream()
715+
.filter(it -> it.getEndTime() == null && !it.isDisabled()).collect(Collectors.toList());
716+
if (!incompleteTests.isEmpty()) {
717+
final Double now = (double) System.currentTimeMillis();
718+
final String sysdate = UtplsqlRunner.getSysdate();
719+
for (Test test : incompleteTests) {
720+
// fix incomplete tests, see https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/107
721+
test.setEndTime(sysdate);
722+
test.setExecutionTime((now - currentRun.getStart()) / 1000);
723+
test.setErrorStack(UtplsqlResources.getString("RUNNER_MISSING_TEST_RESULT_MESSAGE"));
724+
test.getCounter().setError(1);
725+
}
726+
}
727+
// recalculate counters and fix inconsistencies
728+
currentRun.getCounter().setSuccess(0);
729+
currentRun.getCounter().setFailure(0);
730+
currentRun.getCounter().setError(0);
731+
currentRun.getCounter().setDisabled(0);
732+
currentRun.getCounter().setWarning(0);
733+
for (Test test : currentRun.getTests().values()) {
734+
if (test.isDisabled() && test.getCounter().getDisabled() == 0) {
735+
test.getCounter().setDisabled(1);
736+
}
737+
if (test.getFailedExpectations() != null && !test.getFailedExpectations().isEmpty() && test.getCounter().getFailure() == 0) {
738+
test.getCounter().setFailure(1);
739+
}
740+
if (test.getErrorStack() != null && test.getCounter().getError() == 0) {
741+
test.getCounter().setError(1);
742+
}
743+
currentRun.getCounter().setSuccess(currentRun.getCounter().getSuccess() + test.getCounter().getSuccess());
744+
currentRun.getCounter().setFailure(currentRun.getCounter().getFailure() + test.getCounter().getFailure());
745+
currentRun.getCounter().setError(currentRun.getCounter().getError() + test.getCounter().getError());
746+
currentRun.getCounter().setDisabled(currentRun.getCounter().getDisabled() + test.getCounter().getDisabled());
747+
currentRun.getCounter().setWarning(currentRun.getCounter().getWarning() + test.getCounter().getWarning());
748+
}
749+
// terminate run
750+
currentRun.setEndTime(UtplsqlRunner.getSysdate());
751+
double now = (double) System.currentTimeMillis();
752+
currentRun.setExecutionTime((now - currentRun.getStart()) / 1000);
753+
currentRun.setCurrentTestNumber(0);
754+
// update run in GUI
755+
update(currentRun.getReporterId());
756+
}
757+
712758
@SuppressWarnings("DuplicatedCode")
713759
private void initializeGUI() {
714760
// Base panel containing all components
@@ -767,45 +813,18 @@ private void initializeGUI() {
767813
if (currentRun.getConsumerConn() != null) {
768814
// Aborts JDBC Connection. Connection might still run in the background. That's expected.
769815
DatabaseTools.abortConnection(currentRun.getConsumerConn());
770-
for (Test test : currentRun.getTests().values()) {
771-
if (test.getEndTime() == null && !test.isDisabled()) {
772-
test.setDisabled(true);
773-
test.getCounter().setDisabled(1);
774-
test.getCounter().setWarning(1);
775-
test.setWarnings(UtplsqlResources.getString("RUNNER_STOP_TEST_MESSAGE"));
776-
test.setStartTime(null);
777-
}
816+
List<Test> notCompletedTests = currentRun.getTests().values().stream()
817+
.filter(it -> it.getTestNumber() >= currentRun.getCurrentTestNumber() && it.getEndTime() == null && !it.isDisabled())
818+
.collect(Collectors.toList());
819+
for (Test test : notCompletedTests) {
820+
test.setDisabled(true);
821+
test.getCounter().setDisabled(1);
822+
test.getCounter().setWarning(1);
823+
test.setWarnings(UtplsqlResources.getString("RUNNER_STOP_TEST_MESSAGE"));
824+
test.setStartTime(null);
778825
}
779-
// recalculate counters and fix inconsistencies
780-
currentRun.getCounter().setSuccess(0);
781-
currentRun.getCounter().setFailure(0);
782-
currentRun.getCounter().setError(0);
783-
currentRun.getCounter().setDisabled(0);
784-
currentRun.getCounter().setWarning(0);
785-
for (Test test : currentRun.getTests().values()) {
786-
if (test.isDisabled() && test.getCounter().getDisabled() == 0) {
787-
test.getCounter().setDisabled(1);
788-
}
789-
if (test.getFailedExpectations() != null && !test.getFailedExpectations().isEmpty() && test.getCounter().getFailure() == 0) {
790-
test.getCounter().setFailure(1);
791-
}
792-
if (test.getErrorStack() != null && test.getCounter().getError() == 0) {
793-
test.getCounter().setError(1);
794-
}
795-
currentRun.getCounter().setSuccess(currentRun.getCounter().getSuccess() + test.getCounter().getSuccess());
796-
currentRun.getCounter().setFailure(currentRun.getCounter().getFailure() + test.getCounter().getFailure());
797-
currentRun.getCounter().setError(currentRun.getCounter().getError() + test.getCounter().getError());
798-
currentRun.getCounter().setDisabled(currentRun.getCounter().getDisabled() + test.getCounter().getDisabled());
799-
currentRun.getCounter().setWarning(currentRun.getCounter().getWarning() + test.getCounter().getWarning());
800-
}
801-
// terminate run
802-
currentRun.setEndTime(UtplsqlRunner.getSysdate());
803-
double now = (double) System.currentTimeMillis();
804-
currentRun.setExecutionTime((now - currentRun.getStart()) / 1000);
805-
currentRun.setCurrentTestNumber(0);
806826
currentRun.setStatus(UtplsqlResources.getString("RUNNER_STOP_RUN_MESSAGE"));
807-
// update run in GUI
808-
update(currentRun.getReporterId());
827+
fixCountersAndUpdate();
809828
}
810829
});
811830
stopButton.setEnabled(false);
@@ -871,6 +890,9 @@ private void initializeGUI() {
871890
if (currentRun.getExecutionTime() != null) {
872891
time.setSeconds(currentRun.getExecutionTime());
873892
elapsedTimeTimer.stop();
893+
if (!currentRun.getTotalNumberOfTests().equals(currentRun.getTotalNumberOfCompletedTests())) {
894+
fixCountersAndUpdate();
895+
}
874896
} else {
875897
final Double now = (double) System.currentTimeMillis();
876898
time.setSeconds((now - currentRun.getStart()) / 1000);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.