Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [10.0.4] - 2025-08-14

### Added:
- We fixed an issue where renaming or deleting a module resulted in the test suite overview showing incorrect data.

## [10.0.3] - 2025-08-07

### Added:
Expand Down
Binary file added dist/UnitTesting_10.0.4.mpk
Binary file not shown.
Binary file modified src/UnitTesting.mpr
Binary file not shown.
30 changes: 28 additions & 2 deletions src/javasource/unittesting/TestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public void updateTestSuiteCountersAndResult(IContext context, TestSuite testSui
long pendingCount = getTestSuiteCount(context, testSuite, "[Result = '_1_Running' or Result = empty]");

testSuite.setTestCount(testCount);
LOG.trace("Updated test count to " + succeededCount);
LOG.trace("Updated test count to " + testCount);

testSuite.setTestPassedCount(succeededCount);
LOG.trace("Updated test suite succeeded count to " + succeededCount);
Expand Down Expand Up @@ -549,6 +549,11 @@ public synchronized void findAllTests(IContext context) throws CoreException {
updateUnitTestList(context, testSuite);
}

/*
* Remove unit tests from orphaned modules
*/
deleteUnitTestsFromOrphanedModules(context, modules);

/*
* Remove all modules without tests
*/
Expand Down Expand Up @@ -585,7 +590,7 @@ private synchronized TestSuite findOrCreateTestSuite(IContext context, String mo
}
}

private synchronized void deleteTestSuitesWithoutTest(IContext context) throws CoreException {
private synchronized void deleteTestSuitesWithoutTest(IContext context) {
StringBuilder query = new StringBuilder();
query.append(String.format("//%s", TestSuite.entityName));
query.append("[not(" + UnitTest.MemberNames.UnitTest_TestSuite + "/" + UnitTest.entityName + ")]");
Expand All @@ -594,6 +599,27 @@ private synchronized void deleteTestSuitesWithoutTest(IContext context) throws C
Core.delete(context, testSuites);
}

private synchronized void deleteUnitTestsFromOrphanedModules(IContext context, Set<String> currentModules) {
List<IMendixObject> allTestSuites = Core.createXPathQuery("//" + TestSuite.entityName).execute(context);

for (IMendixObject mxObject : allTestSuites) {
TestSuite testSuite = TestSuite.initialize(context, mxObject);

if (!currentModules.contains(testSuite.getModule())) {
StringBuilder query = new StringBuilder();
query.append(String.format("//%s", UnitTest.entityName));
query.append(String.format("[%s=$TestSuite]", UnitTest.MemberNames.UnitTest_TestSuite));

List<IMendixObject> orphanedUnitTests = Core.createXPathQuery(query.toString())
.setVariable("TestSuite", testSuite.getMendixObject().getId().toLong()).execute(context);

if (!orphanedUnitTests.isEmpty()) {
Core.delete(context, orphanedUnitTests);
}
}
}
}

public synchronized void updateUnitTestList(IContext context, TestSuite testSuite) {
try {
/*
Expand Down