Don,
ActivityInstrumentationTestCase2 has a method, getInstrumentation(),
which gives you an Instrumentation object instance that's used in the test.
Instrumentation has getContext() which gives you your test package's
context object, now you can access its resources (as opposed to
resources of the target application - those are under getTargetContext()).
http://developer.android.com/reference/android/app/Instrumentation.html#getContext()
Now you can call getResources() on your test package's context, and the
rest should be easy:
- Either call getAssets() to get AssertManager and then list() to get
the list of script files;
- Define a <integer-array>'s within your test package resources, with
references to individual XML entries, one array per test case. Load the
array with res.getIntArray(), then call res.getXml() to open individual
scripts.
I'd do the latter, to separate the scripts for individual tests from one
another.
Hope this helps.
-- Kostya
25.02.2011 12:58, donV ?????:
Thank you for your reply!
Very possibly there is another solution.
The problem to be solved is that I want to run some test scripts
stored as assets to test multiple activities.
The test scripts need access to the activity to be tested. This is
normally done by subclassing ActivityInstrumentationTestCase2, so my
plan was to generate subclass of ActivityInstrumentationTestCase2 for
each activity to be tested, and let this class scan the assets
directory for related test scripts and run them.
Using junit.framework, I would like to define one TestCase per script,
or multiple TestCase instances per script. If the suite() method of
the ActivityInstrumentationTestCase2 subclass could scan the assets
directory, I would not need to scan for classes. Is this possible?
How can I scan assets in a static context?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en