ingwarsw / arquillian-suite-extension

Arquillian extension that will force single deployment for all tests
Apache License 2.0
67 stars 20 forks source link

Annotated deployment class from Eclipse with Buildship #59

Closed Chewbizz closed 4 years ago

Chewbizz commented 4 years ago

Greetings,

We use Eclipse and gradle to build our projects, and with recent versions of Eclipse Buildship + gradle, we now have the ability to have separate output folders for main classes and test classes. For instance, main classes are built in "/project-root/bin/default" whereas test classes are built in "/project-root/bin/test". This separation allows for a lot of interesting features. However, this is not compatible with the following line of code:

https://github.com/ingwarsw/arquillian-suite-extension/blob/07d6c32b086e390a50b92ace869052303a965012/src/main/java/org/eu/ingwar/tools/arquillian/extension/suite/DeploymentClassFinder.java#L60-L62

On this line, the created Reflections object only takes the URL of the main classes directory ("/project-root/bin/default"). And the class annotated with @ArquillianSuiteDeployment (which is in "/project-root/bin/test") cannot be found.

I would say that it could be fixed quite easily by retrieving all classpath URLs instead, but I think it goes against the idea of the comment above this line of code. According to this comment, if all classpath URLs are used, this may mix up dependent project's classes which may also contain test classes annotated with @ArquillianSuiteDeployment.

There's a kind of conflict there : In "older" setups, dependent projects could come along with their own test classes and "mix up". In our "newer" setup with separated source and test classes, this won't happen, since Eclipse will gracefully ignore test classes of dependent project, but there, arquillian-suite-extension will fail to find our suite deployment class.

If I may, I would suggest a simple property flag on arquillian suite properties, to indicate the Reflection mechanism to use. For instance:

<extension qualifier="suite">
  <property name="fullClasspathScan">true</property>
</extension>

When this is set to true, it would allow to scan all classpath URLs with Reflections, allowing to search for "/project-root/bin/test".

As a workaround, we are using an explicit "deploymentClass", but it is not easy to maintain accross our large codebase.

Thanks in advance for any feedback.

Chewbizz commented 4 years ago

Proposed patch #60

ingwarsw commented 4 years ago

Closed by #60

Chewbizz commented 4 years ago

I could verify that 1.2.1 (with arquillian.xml modified to use "fullClasspathScan") works like a charm. Thanks @ingwarsw for your help and reactivity!