1

I'm new to Java and I am trying to follow the examples on developer.android.com. I'm interested in learning how to test applications. The specific problem I have is that I can't get the test files to run properly. For example, I go to developer.android.com -> Develop -> Samples -> Testing and download the ActivityInstrumentation files. I import them into Eclipse. I get 2 projects (MainActivity and tests). I right-click on "tests" and choose Properties. Under Project References, I check off "MainActivity" (my co-worker told me I should do this to link the projects).

The SampleTests.java file has red squiggly lines under the following:

import com.example.android.activityinstrumentation.MainActivity;
import com.example.android.activityinstrumentation.R;

I, and my co-worker can't figure out what is wrong. I'd really like to run these files.

(If it helps, I am able to get the MainActivity part onto my phone, and I've been playing with clicking all the buttons and other fun things that it demonstrates.)

Thanks in advance for your help.

Stephanie
  • 33
  • 6
  • https://developer.android.com/tools/testing/activity_test.html did you follow the steps here, ignoring what your colleague says to do? – RossC Aug 21 '14 at 13:52
  • No, I haven't gotten that far yet (Spinner and SpinnerTest). I expected the code from the samples to be self-contained and just work right out of the box. I wanted to run them, and see the results, so I could then work through both the main app and the test app line by line. These examples seem more targeted than the one to which you pointed me. I never found this page when I reading through the documentation before. Thanks! I'll try it out. It still doesn't explain why the samples don't run out of the box, though. It's confusing for new users. They should just work. Thanks. – Stephanie Aug 21 '14 at 14:02
  • So I've successfully completed the Spinner and SpinnerTest applications, but that stuff is way over my head. I'd really appreciate getting the samples and their tests working, because those examples are much more granular. – Stephanie Aug 21 '14 at 18:51

1 Answers1

0

Seems like this solves my problem for one of the samples. Doesn't fix the ones I've renamed, though. (They all want to be called MainActivity, and that's just annoying.)

import from another java project in eclipse

Add project A to project B's build path.

Follow these steps: Right click on project B's folder in eclipse --> properties --> build path --> projects --> add. Now add project A

Thanks for everyone's help!

Community
  • 1
  • 1
Stephanie
  • 33
  • 6