[ 
https://issues.apache.org/jira/browse/SLING-5352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15049314#comment-15049314
 ] 

Thierry Ygé commented on SLING-5352:
------------------------------------

[~bdelacretaz] Note also that is we could use junit 4.12 we could also simply 
use both annotation combined for the same field as described in 
https://github.com/junit-team/junit/pull/932

So below would work:
{code}
@Rule
@ClassRule
    public static TeleporterRule classRule = 
TeleporterRule.forClass(SomeTest.class, "Launchpad");
{code}


It works on my maven side , but not on the serverside, I guess it is due to the 
version of junit embedded in Sling JUnit Core version which I think is 4.11 at 
the moment (see 
http://svn.apache.org/repos/asf/sling/trunk/testing/junit/core/pom.xml), so 
that would be a easy fix, should I open another jira for that too ? 

About Eclipse IDE, I see also it's not able to run test that contains 
ClassRule, maybe due to the version of Test runner on Eclipse ? (I tested with 
Eclipse Mars release). It's odd that it works with maven command but not in 
Eclipse IDE. Maybe we need to file a bug for it.



> TeleporterRule should also work as a ClassRule
> ----------------------------------------------
>
>                 Key: SLING-5352
>                 URL: https://issues.apache.org/jira/browse/SLING-5352
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: JUnit Tests Teleporter 1.0.4
>            Reporter: Thierry Ygé
>         Attachments: clientsideteleporter_patch.txt
>
>
> Currently it's not possible to use the TeleporterRule as Rule and ClassRule 
> annotation. 
> The idea is that BeforeClass will create the bundle and install it.
> AfterClass will uninstall it. This will optimize the processing and avoid a 
> lot of round trip  and waits. It still allow to use it as in the original 
> version with only Rule annotation.
> I have made some test , and will attach my suggested solution. It allow to 
> use it as before:
> {code}
>     @Rule
>     public TeleporterRule classRule = 
> TeleporterRule.forClass(SomeMoreTest.class, "Launchpad");
> {code}
> or as follow with a ClassRule annotation:
> {code}
>     @ClassRule
>     public static TeleporterRule classRule = 
> TeleporterRule.forClass(SomeTest.class, "Launchpad");
>     @Rule
>     public TeleporterRule teleporterRule = classRule;
> {code}
> The changes are not so big, it only need a static field to store the bundle  
> symbolic name value in the case it is used with the ClassRule annotation. 
> Then adapt the logic in the statement to differentiate between ClassRule and 
> Rule usages.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to