wso2 / maven-tools

Apache License 2.0
44 stars 59 forks source link

"synapse-unit-test" fails when default test folder not present #114

Open MrLurch81 opened 6 months ago

MrLurch81 commented 6 months ago

Description: The latest version of the Integration Studio (8.2.0) creates a folder "build-artifacts", where pom.xml files are generated for all synapse artifacts. However, by default the synapse-unit-test-maven-plugin is configured to look for a "test" folder in the same location as each pom.xml file (<testCasesFilePath>${project.basedir}/test/${testFile}</testCasesFilePath>). If that folder does not exist, the build fails with the error:

[ERROR] Failed to execute goal org.wso2.maven:synapse-unit-test-maven-plugin:5.2.42:synapse-unit-test (synapse-unit-test) on project foobar_endpoint: Exception occurred while running test cases: null -> [Help 1]

So a solution would be to let the Eclipse plugins generate empty "test" folders everywhere, but the cleaner and more robust solution is to let the synapse-unit-test-maven-plugin not throw an exception when the test folder is not found.

For the latter I have added a check before trying to list all files in the specified test folder. If the folder does not exist, the plugin now cleanly exits and states "Detect 0 Synapse test case files to execute", just like when the test folder is present but does not contain any tests.

After this change, all projects and generated build-artifacts are built correctly.

Affected Product Version: Integration Studio 8.2.0

Steps to reproduce: Create a new ESB project, add an artifact (e.g. endpoint), try to build the project using mvn clean verify. It will fail when building the build-artifacts folder

MrLurch81 commented 6 months ago

Example ESB project attached exampleProject.zip