Construction of the robolectric environment and robolectric
Recently I have been studying Test-Driven Development. Test-Driven Development is a method of extreme programming, we recommend that you write the test code as needed before writing the code (of course, this test code cannot be passed), and then write the formal code based on the test code, the code must pass the test code step by step. If we can a
Robolectric a configuration tutorial on the Web, but I used it to configure it and foundUsethe Mockito.spy function will appear exception. Later on the Powermock official online found another tutorial, which said that using Powermockrule is not reliable, to use the Powermock 1.6.0 introduced by the new @powermockrunnerdelegate annotation to configureThe specific configuration file is as follows: module inside the Build.gradle add dependency:
dep
Android Studio under Gradle robolectric Unit test Configuration1.RobolectricRobolectric is a unit test framework based on JUnit. It does not depend on the testing capabilities provided by Android, it uses shadow objects and runs tests on a normal workstation/server JVM, unlike a simulator or device that requires dexing (Android The Dex compiler compiles the class file into the format used by the Dalvik VM on the Android device, and the process of pack
Robolectric a configuration tutorial on the web, but I used it to configure it and foundUsethe Mockito.spy function will appear Exception. Later on the Powermock official online found another tutorial, which said that using Powermockrule is not
Robolectric there are some bugs, while the use of posture and Mockito have a larger difference, so has not been time to practice. This hope will be able to do a further investigation, the time to share with you the use of feelings.But using Mockito, there is a problem, that is, the static method and the final class, the final method is no way to mock, to this point how to solve, we will introduce later.Using mocks in a test environment: Dependency In
Test-driven Android developmentRunning test cases on an Android emulator or on a real machine is slow. It usually takes a minute or more to build, deploy, and launch apps. This is not a TDD (test-driven development) mode. Robolectric provides a better way.Maybe you've been trying to run test cases directly in the Java IDE using JUnit or testng, but you've been reporting java.lang.RuntimeException: Stub! exceptions.This exception is due to the absence
Related Resources* Using Monkeytalk in Androidstudio
?
Nativedriver
Nativedriver is the implementation of the Webdriver API, which is a native app UI driver, not a Web application.
Oschina Url:?http://www.oschina.net/p/nativedriver
?
Robolectric
Robolectric is an Android unit test framework that uses the Android SDK jar, so you can use test drivers to develop Android apps. The test can be r
Driving the Activity Lifecycle, drivinglifecycle
Before Robolectric 2.2, most tests created Activities by calling constructors directly ,(new MyActivity()) And then manually calling lifecycle methods suchonCreate(). Also widely used were a set of methods inShadowActivity(For instanceShadowActivity.callOnCreate()) That are precursorsActivityController.
It was a mess.ActivityControllerIs a Robolectric API tha
Webdriver protocol. The selendroid can be used on both the emulator and the actual device, as well as the integration of grid nodes for scaling and parallel testing.8. Robolectrichttp://robolectric.org/Robolectric is an Android unit testing framework, but it does not rely on the testing capabilities provided by Android, it implements a set of Android code that the JVM can run, and then intercepts the Android-related code calls as the unit test runs.
the simulator or the real machine, but also to do the use of Android resources testing, such as using the context, browsing resources, files, databases and so on. It's also possible,!!!. Then there's only a third party test framework. Robolectric
666, are you here to do the publicity?-_-、、、 But it is really good to use, but also to solve our pain point.
Then use a demand to explain the robolectric test,
a native app UI driver, not a Web application.Oschina Url:http://www.oschina.net/p/nativedriverRobolectricRobolectric is an Android unit test framework that uses the Android SDK jar, so you can use test drivers to develop Android apps. The test can be run on the workstation's JVM in just a few seconds. Robolectric handles view scaling, resource loading and native C code implementations for a large number of Android devices.
generally recommend the following categories: 70% of small Tests, 20% of medium tests, and 10% for large tests.Small testWhen you add and change the functionality of an application, you ensure that the functionality runs as expected by creating and writing unit tests. Although you can run unit tests in an Android emulator or a real device, it is often quicker and easier to run unit tests in a development environment, and you need to add stubs or mock methods to interact with your Android system
Now, there are a number of Android Automation test architectures or tools available for us to use, including Activity instrumentation, Monkeyrunner, Robotium, and Robolectric. In addition, Lesspainful also provides services for automated testing on real-world devices.Android itself provides basic support for instrumentation testing, One of these is the ActivityInstrumentationTestCase2 class in the Android.test package, which expands the JUnit TestCase
draw can be recorded and played back.NativedriverNativedriver is the implementation of the Webdriver API, which is a native app UI driver, not a Web application.RobolectricRobolectric is an Android unit test framework that uses the Android SDK jar, so you can use test drivers to develop Android apps. The test can be run on the workstation's JVM in just a few seconds. Robolectric handles view scaling, resource loading and native C code implementations
test framework of instrumentation, the current domestic and foreign use of more, more information, the community is more active.Cons: For testers to have a certain Java Foundation, understand the Android basic components. Can't cross apps.9.RobolectricRobolectric is an Android unit test framework that uses the Android SDK jar, so you can use test drivers to develop Android apps. The test can be run on the workstation's JVM in just a few seconds. Robolectric
is responsible for communication between the View layer and the Model layer.
Attention:When we go to achieve a certain presenter, we must pay attention to the Model layer may appear error information to presenter to do the unified treatment. And try to pull the business logic out of the UI layer and put it into the presenter. The first principle of implementing the MVP Architecture Test Principle is to use junit rather than espresso or other third-party automated test frameworks, followed by se
Dimens.xml DRY (do not repeat yourself), define Universal constants??? Don't make a deep viewgroup.??? Avoid processing on the client when using Webviews, beware of memory leaks??? Use robolectric Unit Test, Robotium do UI test??? Use Genymotion as your simulator??? Always use Proguard and dexguard to confuse projectsAndroid SDKPlace your Android SDK in a location unrelated to your home directory or other applications. When you install some Ides that
Android Unit and Integration testing:https://github.com/codepath/android_guides/wiki/android-unit-and-integration-testing
Unit Testing with junit-tutorial:http://www.vogella.com/tutorials/junit/article.html
Android application testing with the Android test framework-tutorial: http://www.vogella.com/tutorials/AndroidTesting/article.html
Robolectric Installation for Unit testing:https://github.com/codepath/android_guides/wiki/
Today, there are a large number of Android self-motivated test architectures or tools available for us to use, including Activity instrumentation, Monkeyrunner, Robotium, and Robolectric. In addition, Lesspainful also provides services to carry out their own active testing on real equipment.Android itself provides basic support for the instrumentation test, One of them is the ActivityInstrumentationTestCase2 class in the Android.test package, which ex
performance after release. In fact, unit tests can find most stupid bugs. Of course, if your App does data processing, unit testing will also help you keep your code working properly.Easy Guide to Android Project Unit testing
I prefer to run unit tests on the JVM because it is much faster than running on the device/emulator.
The Android Gradle plugin can run unit tests on the JVM. Just add the test to it test/ java_or_other_lang .
You can run tests from the IDE (right-click Tes
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.