Closed GoogleCodeExporter closed 9 years ago
A quick update to remind me to investigate the following suggestion
http://stackoverflow.com/questions/3790963/android-how-to-transfer-a-test-fixtur
e-file-to-device-from-unit-test-application
In particular the following comment from Alex
If what you want to do is modify the path to the files the Activity you're
testing uses, you should use !ActivityUnitTestCase and !setActivityContext()
with a RenamingDelegatingContext.
http://developer.android.com/reference/android/test/RenamingDelegatingContext.ht
ml This allows you to redirect file and database access in a context to a new
directory by specifying a directory prefix. You can even use the more complex
constructor to wrap the target context for most operations, but use your test
application's context for file operations, so the activity will access files
stored in the test application rather than the primary application but still
use other resources in the primary application.
Original comment by julianharty
on 18 Jan 2011 at 8:21
Perhaps this will help too
http://stackoverflow.com/questions/2509429/android-pack-resources-into-apk
Original comment by julianharty
on 3 Feb 2011 at 2:35
I ended up establishing a consistent approach to referencing the test data used
by the larger 'unit' tests. All the test data is relative to /sdcard/ e.g.
/sdcard/Books/ for valid DAISY books. There are 3 sub-folders:
* Books - for valid books which the app can also play 'normally'
* problem content - which contains known abberations discovered in real DAISY books
* testfiles - which are a small set of files for specific testing
The /sdcard/ folder can be created 'as-is' on Mac OS X and on linux machines.
For Microsoft Windows it is treated as a root directory on the system drive
(typically C:\sdcard\). Note: Windows (or more likely the Java runtime) copes
with the / character as the directory separator and treats it like Windows' \
character.
When the tests are run using the ant scripts the pre-compile step in the
build.xml for the App (not the one for the tests) copies the test data using
`adb push` to the android device.
When the tests are run with the Eclipse junit test runner, they will fail
unless you've first copied the contents of
http://code.google.com/p/android-daisy-epub-reader/source/browse/#svn%2Ftrunk%2F
files-used-for-testing to /sdcard/ (or C:\sdcard on Windows machines)
There's still more scope to refine the tests e.g. to reduce the number of files
copied; however since the tests do now run relatively well I'm marking this
issue as 'fixed'.
Original comment by julianharty
on 6 Jul 2012 at 7:03
Original issue reported on code.google.com by
julianharty
on 29 Dec 2009 at 5:48