Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing test files in the test project

I wrote some tests that use XML files. I have two project one with code, the second with tests. I would like to store this XML files (they contain some data used during the tests) in the test project. But it is not possible because it seems that only files from src project are loaded to a device. Does anyone know the way to solve this problem ?

like image 849
gregory561 Avatar asked Jul 01 '11 12:07

gregory561


People also ask

How do we organize test data?

One way to organize elements could be to have a folder for each application you are testing and then create a subfolder under there for each page of the application. Elements can be easily moved to different folders by dragging and dropping them. You can also move them to another folder by using the more menu.

How do I upload files to test project tool?

Upload File using XPath - This is an action that requires the XPath of the input element: //input[@type = 'file']. The second parameter is of course, the local path to the file you want to upload. Upload file to input element - This is an element action and you need to use it on the input element.

What are test files?

. test files are used for executing Unit tests for your application. Steps are that you write a . test file with a class that extends DrupalWebTestCase (or DrupalUnitTestCase). In this class you add a static function getInfo() that returns an array with information about the test.


1 Answers

Suppose you got assets folder in both android project and test project, and you put the XML file in the assets folder. in your test code under test project, this will load xml from the android project assets folder:

getInstrumentation().getTargetContext().getResources().getAssets().open(testFile);

This will load xml from the test project assets folder:

getInstrumentation().getContext().getResources().getAssets().open(testFile);

Make sure your TestCase class extends android.test.InstrumentationTestCase instead of android.test.AndroidTestCase to access this.getInstrumentation() method.

like image 79
yorkw Avatar answered Sep 30 '22 09:09

yorkw