[arquillian-issues] [JBoss JIRA] (ARQ-2170) RulesEnricher doubles each test enrichment
Matous Jobanek (JIRA)
issues at jboss.org
Thu Feb 1 03:13:00 EST 2018
[ https://issues.jboss.org/browse/ARQ-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13527041#comment-13527041 ]
Matous Jobanek commented on ARQ-2170:
-------------------------------------
Hi,
thanks for reporting this issue.
> 1. RulesEnricher is not implementor of TestEnricher, so it cannot be overrided through LoadableExtension.
The {{RulesEnricher}} cannot be an implementation of the {{TestEnricher}} because {{TestEnrichers}} are called in a later phase than the rules are created. That's why it is an observer that observes the event {{RulesEnrichment}} that is invoked before the other test enrichers. For more information see this issue https://issues.jboss.org/browse/ARQ-2034
> 2. RulesEnricher#enrichRulesAndTestInstance adds into collection toEnrich test instance:
It is known that it does the double enrichment of the test instances, unfortunately, it is there for a purpose. The rules can be created inside of the test classes as an anonymous class that is using fields from the test class itself:
{code:java}
@ArquillianResource
URL url;
@Rule
public TestRule rule = new TestRule() {
public Statement apply(final Statement base, Description description) {
doSomethingWithUrl(url);
return new Statement() {
@Override
public void evaluate() throws Throwable {
base.evaluate();
}
};
}
};
{code}
For this purpose, it is necessary to inject the fields also into the test class. The second enrichment is then performed in the standard enrichment phase.
> RulesEnricher doubles each test enrichment
> ------------------------------------------
>
> Key: ARQ-2170
> URL: https://issues.jboss.org/browse/ARQ-2170
> Project: Arquillian
> Issue Type: Bug
> Components: core
> Environment: arquillian-junit-core-1.1.11.Final (all versions affected)
> Reporter: kostd kostd
>
> RulesEnricher created in ARQ-1954
> 1. RulesEnricher is not implementor of TestEnricher, so it cannot be overrided through LoadableExtension.
> 2. RulesEnricher#enrichRulesAndTestInstance adds into collection toEnrich test instance:
> {code}
> toEnrich.add(event.getTestInstance());
> {code}
> https://github.com/arquillian/arquillian-core/blob/master/junit/core/src/main/java/org/jboss/arquillian/junit/RulesEnricher.java
> So, if MyTest have`nt field rules, will be only one MyTest enrichment. If MyTest contains one or more test rule, will be two MyTest enrichments.
> Each testEnrichment of MyTest do a soap call to server to prepare data for test. It is very important to me, one or two soap call will happen.
> How can I change this behaviour?
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the arquillian-issues
mailing list