I have a series of Java classes which have programmatic UI layouts; the structure of the layouts varies throughout the running of the classes and is dependent on user responses so I cannot create them as fixed layouts in an xml file. I am now at the stage that I need to test the classes and am wrestling with the Android ans Eclipse testing using JUnit. I cannot seem to workout how to test these programmatic UI’s as their id’s are assigned when they are created. I know what the id’s are (I assign the id using setId(100 +i) where i is the loop variable) but cannot access these id’s in the test project. I have tried findViewById(SandS.Med.NurseCalc.101) but it does not seem to work. I am trying this in my setUp() module.
Can anyone either help with this item or point me in the direction of a site that looks at testing in a more practical way rather than the rather theoretical and complex way in the android.developer site.
Thanks in anticipation.
I have a series of Java classes which have programmatic UI layouts; the structure
Share
I find mocking extremely usefull for testing programatic android stuff. I recommend jMockit
for this purpose ( IMHO, best mocking framework around )
In this unit test I test specific Vew retrieval:
https://github.com/ko5tik/andject/blob/master/src/test/java/de/pribluda/android/andject/ViewInjectionTest.java