How does an android test project have visibility on classes from the main project?
I'm trying to understand how testing can be applied in android and have followed this walkthrough on the Google site.
I've created a project for the application itself via the wizard in IntelliJ. Then I've created a test project using the following :
android create test-project -m ../TestableProject -n TestableProjectTests -p TestableProjectTests
I've opened up the test project, and had a look at the MyActivityTest
class it auto generated, however it seems unable to resolve the location of MyActivity
in the main project, for example this doesn't work :
import com.example.MyActivity;
My question is, how can the test project have visibility on classes from the main application project its trying to test? I can see the following in the manifest of the test project but that doesn't seem to help a g开发者_运维百科reat deal :
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example"
android:label="Tests for com.example"/>
How can I enable my test project to see my application project?
Thanks
Found an answer that worked for me.
Since I'm using intelliJ, I needed to import the test project into the main project as a module. It uses the same project files, just makes it visible as a module so the projects can see each other
Documented here : http://blogs.jetbrains.com/idea/2010/09/android-unit-testing-support/
精彩评论