You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Mridul Pathak (Jira)" <ji...@apache.org> on 2026/07/29 09:10:00 UTC
[jira] [Commented] (OFBIZ-13402) Test source files should be moved from src/main/ to src/test/ to avoid inclusion in production release artifacts
[ https://issues.apache.org/jira/browse/OFBIZ-13402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18099996#comment-18099996 ]
Mridul Pathak commented on OFBIZ-13402:
---------------------------------------
This ticket's fix was only partially carried over to release24.09. Trunk's commit (\{{5a40cc1ee0}}) paired the \{{src/main/groovy}} -> \{{src/test/groovy}} move with a \{{build.gradle}} change adding \{{sourceSets.test.runtimeClasspath}} to \{{ofbiz --test}} tasks' classpath. The release24.09 commits (\{{fdfc2f061f}}, \{{a185b03b9c}}) moved the same files but never made that change, so \{{ofbiz --test}} now throws \{{ClassNotFoundException}} for the relocated classes, and \{{testIntegration}} silently skips ~44 of them while still reporting BUILD SUCCESSFUL.
A straight cherry-pick isn't safe there since release24.09 is still on JUnit 4 rather than JUnit Jupiter -- dropping the sourceSet's \{{include}} restriction outright would make Gradle's \{{test}} task try to execute these OFBizTestCase classes directly. Filed OFBIZ-13469 to track a release24.09-specific fix.
> Test source files should be moved from src/main/ to src/test/ to avoid inclusion in production release artifacts
> ----------------------------------------------------------------------------------------------------------------
>
> Key: OFBIZ-13402
> URL: https://issues.apache.org/jira/browse/OFBIZ-13402
> Project: OFBiz
> Issue Type: Improvement
> Components: framework/base, framework/service
> Affects Versions: 24.09.05
> Reporter: aldous liu
> Assignee: Mridul Pathak
> Priority: Major
> Fix For: Upcoming Branch, 24.09.08
>
>
> Multiple test source files (Groovy test classes) are located under src/main/groovy/ directories instead of
> src/test/groovy/ across the codebase. This results in test code being compiled into the production JARs and
> distributed as part of the official release.
> Reproducer
> After building the project, the following test classes appear in the compiled output:
> # Example check
> jar tf build/libs/ofbiz.jar | grep -E 'SimpleTests|ServicePurgeTest'
> Affected Files
> The following 28 test files are in src/main/ instead of src/test/:
> framework/
> - framework/base/src/main/groovy/org/apache/ofbiz/base/test/SimpleTests.groovy
> - framework/service/src/main/groovy/org/apache/ofbiz/service/test/ServicePurgeTest.groovy
> applications/party/
> - applications/party/src/main/groovy/org/apache/ofbiz/party/party/test/ContactMechWorkerTests.groovy
> - applications/party/src/main/groovy/org/apache/ofbiz/party/party/test/PartyContactMechTests.groovy
> - applications/party/src/main/groovy/org/apache/ofbiz/party/party/test/PartyStatusChangeTests.groovy
> - applications/party/src/main/groovy/org/apache/ofbiz/party/party/test/PartyTests.groovy
> applications/product/
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/CategoryTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/CostTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/InventoryTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductConfigTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductFeatureTypeTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPriceTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoActionTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductPromoCondTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductTagTest.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductTest.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ProductTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/product/product/test/ShipmentTests.groovy
> - applications/product/src/main/groovy/org/apache/ofbiz/shipment/product/test/ShipmentCostTests.groovy
> applications/order/
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/CustRequestPermissionCheckTests.groovy
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/OrderRequirementTests.groovy
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/OrderReturnTests.groovy
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/OrderTests.groovy
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/QuoteTests.groovy
> - applications/order/src/main/groovy/org/apache/ofbiz/order/order/test/ShoppingListTests.groovy
> applications/marketing/
> - applications/marketing/src/main/groovy/org/apache/ofbiz/marketing/marketing/test/MarketingTests.groovy
> plugins/
> - plugins/assetmaint/src/main/groovy/org/apache/ofbiz/assetmaint/assetmaint/test/FixedAssetMaintTests.groovy
> - plugins/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/order/test/OrderNotificationTests.groovy
> Plus their corresponding test definition XMLs under testdef/ directories (e.g., framework/base/testdef/basetests.xml,
> framework/service/testdef/servicetests.xml).
> Expected Behavior
> - All test source files should reside under src/test/groovy/ (or src/test/java/)
> - The build output should not contain test classes
> - Standard Maven/Gradle conventions (src/main for production, src/test for tests) should be followed
> Actual Behavior
> - Test classes are intermixed with production code under src/main/groovy/.../test/
> - They are compiled and packaged into production artifacts
> - No equivalent src/test/ directory structure exists for these files
> Impact
> 1. Artifact bloat: Production JARs include unnecessary test code
> 2. Convention violation: Mixing test and production code contradicts standard Maven/Gradle project layout
> 3. Security: Test hooks or bypasses inadvertently exposed in production classpath
> 4. Maintainability: Confusing code organization for new contributors
> Proposed Fix
> 1. Move each *Tests.groovy file from src/main/groovy/.../${module}/test/ to src/test/groovy/.../${module}/test/
> 2. Update any internal path references in test definition XML files
> 3. Verify build.gradle correctly separates main and test source sets
> 4. Verify the build no longer includes test classes in production artifacts
> Additional Context
> This was observed while analyzing the OFBiz codebase for production deployment. The framework/testtools component
> already correctly serves as the dedicated test infrastructure module — test code within other framework/ and
> applications/ modules should follow the standard src/test/ layout.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)