Wednesday 15 January 2014

Android Studio simple Unit Test not working -


I am trying to test a simple unit in Android Studio and it is not working. I have tried to follow a lot of tutorials but have not had any success till now

When I run the test, this error message is shown:

  Java.lang.RuntimeException: android.test.ActivityInstrumentationTestCase2 did not set up the method.  

My test class:

  Public class increases main activityText activity increases testcase2 & lt; Main activity & gt; {Public key activity activity; Public main activity () {super (main activity category); } @private virus set up () before exception {super.setUp (); Activity = getActivity (); } @Test Public Zero testApp () throws an exception {assertTrue (true); } Public Zero Tyrundown after @ throws exception {super.teardown (); Activity.finish (); }}  

MainActivity.class:

  public class increases main activity activity {@ Override Protected Zero (bundled Instantstate) {super .onCreate (savedInstanceState); SetContentView (R.layout.activity_main); }}  

build.gradle (app):

  Apply the plugin: 'com.android.application' android {compileSdkVersion 21 buildToolsVersion "21.1.2 "DefaultConfig {applicationId" com.helloworld.tripbudget "minSdkVersion 19 targetSdkVersion 21 versionCode 1 versionName" 1.0 "} {buildTypes release {minifyEnabled false proguardFiles getDefaultProguardFile ('ProGuard-android.txt'), 'proguard-rules.pro'}}} Dependency {FileTree compilation (includes: ['* .jar'], dir: 'libs') compilation 'com.android.support:appcompat-v7:22.0.0' testCompile 'JUnit: JUnit: 4.12' testCompile "org. Mockito: mockito core: 1. + "files ('libs / ormlite-android-4.49-SNAPSHOT.jar') compile files ('libs / ormlite core-4.49-SNAPSHOT.jar')} Collection  

o P answers yourself:

Add the code below to create .gradle:

  android {// ... testOptions {unitTests. ReturnDefaultValues ​​= true}}  


No comments:

Post a Comment