question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add getter for @Rule in a RuleChain

See original GitHub issue

I have this

@Rule
 public ActivityTestRule<MainActivity> mActivityTestRule
          = new ActivityTestRule<>(MainActivity.class);
  @Rule
  public ActivityTestRule<QuizActivity> mQuizActivityRule
          = new ActivityTestRule<>(QuizActivity.class, false, false);

  public ActivityTestRule<InsectDetailsActivity> mDetailActivityRule
          = new ActivityTestRule<>(InsectDetailsActivity.class, false, false);

  @Rule
  public RuleChain rules = RuleChain.outerRule(mActivityTestRule)
          .around(mQuizActivityRule)
          .around(mDetailActivityRule);

I want to do something like

rules.getrule().around(0).launchActivity();

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kcooneycommented, Jul 21, 2017

I don’t see how we could write a signature for your proposed method that would not require a cast.

0reactions
Ehbraheemcommented, Jul 21, 2017

@panchenko Thanks for that. But I still think that feature is worth implementing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't be lazy, use @Rules - Nicola Corti
In this way, getters and setters for timingRule won't be created and it will be exposed as a field. Conclusions. Do you want...
Read more >
RuleChain (JUnit API)
The RuleChain rule allows ordering of TestRules. You create a RuleChain with outerRule(TestRule) and subsequent calls of around(TestRule) :
Read more >
How can I use @Rule? - Kotlin Discussions
You can now achieve this with the @JvmField annotation, which instructs the compiler not to generate a getter or setter, and expose it...
Read more >
Kotlin and new ActivityTestRule : The @Rule must be public
JUnit allows providing rules through a test class field or a getter method. What you annotated is in Kotlin a property though, which...
Read more >
Ordering your JUnit Rules using a RuleChain - hasCode.com
Adding JUnit; Rule definition; Applying the Rule to a Test Case; Ordering Rules with RuleChains; Ordering ClassRules with RuleChains ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found