views:

449

answers:

2

I have seen all the examples on the web and it seems real simple. I have a bare-bones app that displays a string. I have a a Android JUnit test project that I created when the app was being created (ecclipse asked if I wanted to create a test app).

When I run the test app (Run As --- Android JUnit) I see the foolowing in the console....

[2010-02-27 00:45:03 - SimpleCalculatorTest]Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554 [2010-02-27 00:45:12 - SimpleCalculatorTest]Test run complete

I do not see any of the code in the testcase being called. My testcase is a class that extentds ActivityInstrumentationTestCase2. DDMS log shows : 02-27 00:44:58.521: WARN/TestGrouping(1275): Invalid Package: '' could not be found or has no tests

Any ideas? I have tried everything....

A: 

It might be something simple..

Can you post your full package name of application and test projects?

Fred Grott
I have two folders at the same levelSimpleCalculator package="android.Calculator"SimpleCalculatorTest package="android.Calculator.test"The test code has one file (test2.java)which has one testCase class:public class Test2 extends ActivityInstrumentationTestCase2<SimpleCalculator> thanks!
nik
So is your testcases in a separate test project or in your org project?You should have two project folders..one with your org app project and one with your testcases for the app project..ie your texstcases with have different package name..for exampleMobileBytesSplashcom.mobilebytes.mobilebytessplashMObileBytseSplasTestcom.mobilebytes.mobilebytessplashtest
Fred Grott
Hey Fred, I figured out the issue. My testcase functions did not begin with the word test! Hense they were not being found. Its surprising that in all the adroid testing documentation that I read, I did not see a note saying that the testfunctions have to start with test (testFunc1, testFunc2.....). Maybe I was not looking!
nik
Well, since its based on junit maybe they thought it was obvious..
Fred Grott
You should post this as an answer and accept it later on
Janusz
+2  A: 

If you create a new ActivityInstrumentationTestCase2 then you need a default constructor that points to the class that you want to test.

ex:

public class TestappTest extends ActivityInstrumentationTestCase2<AppUnderTest> {

  public TestappTest() {
    super("my.package.app", AppUnderTest.class);
  }

  public void testApp() {
      // Testcase
  }
}
repoc