Skip to content

Commit 906e2ff

Browse files
committed
[UIA-827] Update test suite result for individual test run
1 parent 0efedd9 commit 906e2ff

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/javasource/unittesting/TestManager.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ else if (parts.length == 2) // method-scale test run
120120

121121
junit.run(request);
122122
}
123+
updateTestSuiteFailedCountAndResult(context, testSuite);
123124
}
124125

125126
private void runMfSetup(TestSuite testSuite) {
@@ -379,6 +380,36 @@ private boolean runMicroflowTest(String mf, UnitTest test, TestSuite testSuite)
379380
}
380381
}
381382

383+
private void updateTestSuiteFailedCountAndResult(IContext context, TestSuite testSuite) throws CoreException {
384+
long testSuiteObjectId = testSuite.getMendixObject().getId().toLong();
385+
386+
StringBuilder baseQuery = new StringBuilder();
387+
baseQuery.append(String.format("//%s", UnitTest.entityName));
388+
baseQuery.append(String.format("[%s=$TestSuite]", UnitTest.MemberNames.UnitTest_TestSuite));
389+
390+
long failedCount = Core.createXPathQuery(baseQuery + "[Result = '_2_Failed']")
391+
.setVariable("TestSuite", testSuiteObjectId).execute(context).size();
392+
393+
if (failedCount > 0) {
394+
testSuite.setResult(UnitTestResult._2_Failed);
395+
testSuite.setTestFailedCount(failedCount);
396+
testSuite.commit();
397+
LOG.trace("Update test suite failed count to " + failedCount + " and result to 'Failed'");
398+
return;
399+
}
400+
401+
long pendingCount = Core.createXPathQuery(baseQuery + "[(Result = '_1_Running' or Result = empty)]")
402+
.setVariable("TestSuite", testSuiteObjectId).execute(context).size();
403+
404+
if (pendingCount > 0)
405+
return;
406+
407+
testSuite.setResult(UnitTestResult._3_Success);
408+
testSuite.setTestFailedCount(0L);
409+
testSuite.commit();
410+
LOG.trace("Reset test suite failed count and update result to 'Success'");
411+
}
412+
382413
private void commitSilent(UnitTest test) {
383414
try {
384415
test.commit();

0 commit comments

Comments
 (0)