[ 
https://issues.apache.org/jira/browse/OFBIZ-13402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18078633#comment-18078633
 ] 

Jacques Le Roux commented on OFBIZ-13402:
-----------------------------------------

Thanks Aldous,

I only read the title and that sounds totally appropriate to me. There is 
already 53 files following this advice. I guess that following your description 
will help.

> 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
>            Priority: Major
>
> 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)

Reply via email to