Tuesday, 15 February 2011

Android Studio running unit test shows 'Empty test suite' -



Android Studio running unit test shows 'Empty test suite' -

i want start writing unit tests applications cannot 1 simple test run. have created little application seek how unit test should setup , run, no test run , 'empty test suite'.

i using android studio 0.6.1 gradle 1.12

here folder structure:

myactivitytest.java

package com.vist.testableapp.tests; import android.content.intent; import android.test.activityunittestcase; import android.test.suitebuilder.annotation.smalltest; import android.widget.button; import com.vist.testableapp.myactivity; import com.vist.testableapp.r; public class myactivitytest extends activityunittestcase<myactivity> { public myactivitytest(class<myactivity> activityclass) { super(activityclass); } button btn1; @override public void setup() throws exception { super.setup(); startactivity(new intent(getinstrumentation().gettargetcontext(), myactivity.class), null, null); btn1 = (button)getactivity().findviewbyid(r.id.button1); } @smalltest public void testfirst() { assertequals("btn1",btn1.gettext()); } }

application's build.gradle

apply plugin: 'android' android { compilesdkversion 19 buildtoolsversion "19.1.0" defaultconfig { applicationid "com.vist.testableapp" minsdkversion 15 targetsdkversion 15 versioncode 1 versionname "1.0" testapplicationid "com.vist.testableapp.tests" } buildtypes { release { runproguard false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) }

could point out doing wrong or missing? searched in none of answers helped me.

the constructor should this:

public myactivitytest() { super(myactivity.class); }

i need larn not rely much on ide's code template provided constructor parameter. resolved colleague , http://siemprepreguntando.blogspot.de/2013/07/running-tests-test-running-startedtest.html

android unit-testing android-gradle

No comments:

Post a Comment