-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use @ArquillianResource instead of @RubyResource to inject test resources #1
Comments
In general @ResourceProviders are intended just as a hook to Inject resources, not as a place to do work. In your case I guess a @observes EventContext could work. AroundInvoke the Test event. Or possible just in Before as you have no 'After' behavior. You then have to know about if this is a MethodLevel or not and produce/operate on the correct Ruby script container for later to inject that instance back in the ResourceProvider. |
… fields annotated with @ArquillianResource
@aslakknutsen Do you think firing a JRubyScriptExecution event from a Before observer or ResourceProvider.lookup() depending on class or method based script execution is a reasonable solution? |
A bit skeptical about the event fired in ResourceProvider but.. Doesn't sound too bad. Another approach I guess would be to;
|
OK, I could already create the method level ScriptingContainer here in the Before observer: Then the ResourceProvider would get even simpler because it's only returning an instance that is already created. Great idea. Thank you! |
@aslakknutsen Only thing I find a bit disturbing about
is that it makes the extension inspect the class for @ArquillianResource ScriptingContainer and Ruby fields if I want to create the instance only on demand. So I would have to duplicate this code: |
Essentially yeah. Planning a nicer API around that kinda reflection work but.. testClass.getClass().getDeclaredFields().each { it.type == Ruby|SciptContainer && it.isAnnotationPresent(ArquillianResource)} |
Thank you! Just updated the PR #2. It is so much cleaner now (except for searching ArquillianResource annotations on the fields;-) ) |
Currently Ruby and ScriptingContainer instances are injected on the test class or method if an annotation @RubyResource is present, e.g.:
To align the resource injection with other arquillian resource this should be changed to using @ArquillianResource as well.
@ArquillianResource requires a ResourceProvider to return the resource in ResourceProvider.lookup() .
Until arquillian-core 1.1.7.Final it was not possible to distinguish a field injection from a parameter injection.
Therefore I used the @RubyResource annotation so that the resource is created by a TestEnricher that has access to the concrete method.
Since 1.1.8.Final it is possible to distinguish field from parameter injection so that the way to using @ArquillianResource is open again.
Unfortunately one thing is still missing:
Before the test method is executed scripts defined in the @rubyscript annotation have to be executed on a Ruby instance:
Following solutions are possible imo:
The text was updated successfully, but these errors were encountered: