1

I'm using the newer way to instantiate Android's UiAutomator that utilizes the InstrumentationRegistry to retrieve the context. The problem is that the new methodology for automation doesn't extend UiAutomatorTestCase or any set of classes that can pass parameter to retrieve via getParams() in other tests. I tried making static variables but they seem to reset after each case.

I was wondering what the newer methodology of adding retrievable parameters was? I also can't seem to find a dupe question which is why I'm posting this...

EDIT:

As another note to the original question, this is a completely automated test suite that has nothing to do with our main application. It still uses the standard UI automator functionality but is a separate code project.

So basically I'm just looking to store results from one @Test scenario to the next @Test scenario that runs in succession.

Thank you

KoalaKoalified
  • 687
  • 4
  • 15

1 Answers1

0

You should use InstrumentationRegistry.getArguments(). It returns the same Bundle of command line arguments as UiAutomatorTestCase.getParams().

Allen Hair
  • 1,021
  • 2
  • 10
  • 21
  • Does this also work with black box testing (IE completely parallel program from the main application) – KoalaKoalified Mar 04 '16 at 19:29
  • I'm not sure what you mean. Can you edit your question with more details? – Allen Hair Mar 04 '16 at 19:33
  • Done. Does that clarify slightly? – KoalaKoalified Mar 04 '16 at 19:43
  • A little. Although this goes against best practices (@Test methods should not share state), it should be possible to achieve this with static fields. See this similar question: http://stackoverflow.com/questions/11410691/how-do-i-share-state-between-junit-tests – Allen Hair Mar 04 '16 at 22:39