Questions tagged [android-junit]

Android testing is based on JUnit. In general, a JUnit test is a method whose statements test a part of the application under test.

History:

For a history of JUnit, visit this Wikipedia page.

About Androids JUnit:

Android's build and test tools assume that test projects are organized into a standard structure of tests, test case classes, test packages, and test projects.

Android testing is based on JUnit. In general, a JUnit test is a method whose statements test a part of the application under test. You organize test methods into classes called test cases (or test suites). Each test is an isolated test of an individual module in the application under test. Each class is a container for related test methods, although it often provides helper methods as well.

In JUnit, you build one or more test source files into a class file. Similarly, in Android you use the SDK's build tools to build one or more test source files into class files in an Android test package. In JUnit, you use a test runner to execute test classes. In Android, you use test tools to load the test package and the application under test, and the tools then execute an Android-specific test runner.

Reference: https://developer.android.com/tools/testing/testing_android.html

Example Questions:

Documentation:

82 questions
0
votes
1 answer

connectedAndroidTest task runs all test even when class is specified

I m trying to run instrumented unit tests using connectedAndroidTest. At first I jus wanted run to particular class using cAT. So I tried below command ./gradlew app:connectedAndroidTest…
Arvind
  • 33
  • 1
  • 6
0
votes
1 answer

Unit Test onSaveInstanceState with ActivityRules

I'm trying to figure out how to test onSavedInstance using the newer AndroidJunit4 and Activity Rules. @RunWith(AndroidJUnit4.class) public class MyViewActivityTest{ @Rule public UiThreadTestRule uiThreadTestRule = new…
JPM
  • 9,077
  • 13
  • 78
  • 137
0
votes
1 answer

Android unit testing for audio recorder

How can I write unit testing for an audio recorder module ? As per my current progress, it's only creating the file and no data is written into it since the recorder started & stopped eventually.
Vineeth
  • 150
  • 1
  • 13
0
votes
1 answer

Better error reporting for Android JUnit4 test runner?

I am using AndroidJUnit4 as my test runner for android espresso and uiautomator test. The html report generated gives no stack trace information or custom error messages. Is there a way to get detailed report?
Prabin Timsina
  • 2,131
  • 3
  • 16
  • 27
0
votes
1 answer

AndroidJUnit test does not find design support snackbar on API level 17 device

I have an AndroidJUnit4 testcase, within this test case I'm using the following code to verify that the snackbar is displayed and contains the right…
Peter
  • 10,910
  • 3
  • 35
  • 68
0
votes
1 answer

Android Studio : transformClassesWithJarMergingForDebugAndroidTest FAILED

I execute Gradle command inside android studio terminal for running project tests. ./gradlew connectedCheck --stacktrace I got the following error : :app:compileDebugAndroidTestAidl…
-1
votes
1 answer

Manifest file error while execute first Android instrumented test

Am getting following error while am trying to execute android example instrumented test. As this is my first instrumented test which am getting error. Here is my Manifest file and gradle file. Android version 3.4.1 java version "1.8.0_152" Am new to…
1 2 3 4 5
6