Okay, sorry I failed at a. fully understanding the new concept and b. not 
explaining my problem with my old tests. 

My problem after the update with my old tests was that they seemingly 
didn't have access to the Rescources anymore. Suddenly all tests that made 
use of Strings (R.string.something) with the error 'could not find String 
Resource 0x12345567.' 

That problem seems to have solved itself miracolously, perhaps since using 
gradle plugin 1.1.3? 
Well, they run now. 

Another question though: is it possible to access Resources from tests run 
under the new feature? I askes the question here 
http://stackoverflow.com/questions/28960898/getting-context-in-androidtestcase-or-instrumentationtestcase-in-android-studio/
 
and people claim they can, but I couldn't no matter what I tried. 

Am Donnerstag, 19. März 2015 02:42:03 UTC+1 schrieb Michal Bendowski:
>
> Hi Florian,
>
> The unit testing support is not meant to replace running tests on a 
> device, they allow you to write a new kind of tests with a shorter 
> iteration time. Most likely, you won't be able to easily convert your 
> existing tests to unit tests that mock out all the platform code.
>
> So in short: you should still be running your tests the "old" way. What 
> exactly is the problem after the upgrade? Can you file a bug at 
> b.android.com?
>
> Thanks,
>
> Michal
>
> On Wed, Mar 18, 2015 at 2:56 PM florian weigl <[email protected] 
> <javascript:>> wrote:
>
>> I had my test setup as follows: 
>>
>> Tests in the src/androidTest folder, Run Configuration 'Android tests', 
>> all in module, no specific TestRunner set (Pic1). 
>> Running my configuration brought up the Run view (shown in Pic2 without 
>> running tests) and the tests were run  on a connected device, same for 
>> starting the tests with 
>> gradlew connectedCheck
>>
>> After the update to 1.1.0 and the introduction of the new 'unit test 
>> feature' none of my tests worked the old way. I tried to get them running 
>> the new way following this 
>> http://tools.android.com/tech-docs/unit-testing-support guide. 
>> I have the following problems with this: 
>>
>> 1. When started from the IDE with rightclick -> run, I receive the error 
>> message
>>
>> java.lang.RuntimeException: Method getInstrumentation in android.test.
>> InstrumentationTestCase not mocked. See https://
>> sites.google.com/a/android.com/tools/tech-docs/unit-testing-support for 
>> details.
>>     at android.test.InstrumentationTestCase.getInstrumentation(
>> InstrumentationTestCase.java)
>>     at CriterionTemplateTest.setUp(CriterionTemplateTest.java:32)
>>
>> although I explicitly added 
>>
>> android {
>>   // ...
>>   testOptions { 
>>     unitTests.returnDefaultValues = true
>>   }
>> }
>>
>> to my build.gradle as advised in the guide. 
>>
>> 2. When I run the tests from the command line with 
>> gradlew testDebug
>>
>> the tests do run, most of them throw an exception though because 
>> getContext() // in AndroidTestCase
>>
>> and 
>>
>> getInstrumentation().getContext() // in InstrumentationTestCase
>>
>> both return null, so I don't have a Context and can't access my 
>> Resources. I tried using 
>> new Activity()
>>
>>
>> as Context, but it also fails to provide the Resources. 
>>
>> So I tried getting back to the old ways of running tests on a device. I 
>> explicitly set the test folder to the old convention of /src/androidTest 
>> with 
>>     sourceSets{
>>         test{
>>             java.srcDirs = ['src/androidTest']
>>         }
>>     }
>>
>> use my old build.gradle and Run Configuration. Running this Run 
>> Configuration fires up the view of Pic2, but tells me that I have an 
>> empty test suite
>>
>> this not running my tests. 
>>
>> So first of all it would be nice if updates to AS would not break working 
>> configurations without prior warning, especially since it is now put of 
>> beta and the official development tool. 
>>
>> Second of all: do you guys have any ideas on how I can get my tests back 
>> to work with full access to the projects resources, assets etc. ? Either 
>> the old or the new way. 
>>
>> Best regards, Florian 
>>
>>
>>
>>
>> Pic 1: 
>> Pic2: 
>>
>>
>> <https://lh4.googleusercontent.com/-2LkgN0o4Sfc/VQHAlX9Fs8I/AAAAAAAAD1Y/2BoQ7MT_Z9U/s1600/empty.png>
>>
>> <https://lh3.googleusercontent.com/-y4dEbyNumDY/VQG5vTpY3HI/AAAAAAAAD1I/vaXSNw1jIlc/s1600/runconfig.png>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "adt-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to