ingwarsw / arquillian-suite-extension

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

Not finding ArquillianSuiteDeployment-annotated class when using Tomcat/TestNG #43

Closed rwalkerands closed 6 years ago

rwalkerands commented 7 years ago

Hi. I'm using a managed Tomcat 7 container and TestNG tests.

Sorry, I can't easily tell whether it's Tomcat, TestNG, or the combination of these that's causing my problem. (I note that others (#27) have reported that the Suite works with TestNG, but with Wildfly as the container.)

The ArquillianSuiteExtension.getDeploymentClass() method doesn't find my @ArquillianSuiteDeployment-annotated deployment class. The issue seems to be the way Reflections is used to try to find it:

final Reflections reflections = new Reflections(ClasspathHelper.contextClassLoader().getResource(""));

I added some logging to my @BeforeSuite-annotated startup method to print out the value of ClasspathHelper.contextClassLoader().getResource("").

It turns out that the result of this can be (depending on whether I run the suite from a command-line Ant task or from within Eclipse, which is a bit confusing) a directory in the file system that contains only configuration files, or a directory that does contain some of the project's class files ... just not the one that's annotated. The point is: for me, getResource("") can return a "wrong" directory in which to ask Reflections to look for the annotated class file.

If I change the line to:

final Reflections reflections = new Reflections("au.org.ands.vocabs");

... where au.org.ands.vocabs is a convenient parent package (the annotated class is actually in the package au.org.ands.vocabs.toolkit.test.arquillian), the annotated class is found correctly.

So, I have a workaround ... but it is obviously specific for my project, and it involves changing the code in ArquillianSuiteExtension. So it would be nice to have the getDeploymentClass() method be a bit "smarter" for this case.

See also #18.

ingwarsw commented 7 years ago

Could you try using one from branch feature/configure_by_xml.

Then confugure extension thru arquillian.xml like that:

<extension qualifier="suite">
    <property name="deploymentClass">org.eu.ingwar.tools.arquillian.extension.suite.Deployments</property>
</extension>

If it will work for you I will create new release..

rwalkerands commented 7 years ago

Wow, that was fast.

I can confirm that this works perfectly for my setup.

ingwarsw commented 7 years ago

Ok so I will try to add readme paragraph about that and release new version..

ingwarsw commented 6 years ago

@rwalkerands Just released new version 1.2.0 with contains that changes.. Could you check if it will work for you?

rwalkerands commented 5 years ago

Just updated my setup to this combination:

This combination does indeed work for me.