Download kotlin Programming APP on PlayStore
Download Website SEO Lessons APP on PlayStore
Android Studio 2.2 preview provides several new toys, very useful, as follows:
- Espresso Test Recorder
- Dependencies Management
- APK analyzer
- View the merged sources for AndroidManifest.xml
Espresso Test Recorder
Espresso is a UI unit testing framework, Test Recorder is the name suggests is used to record UI unit testing tools, it contains a few functions:
- Record the interaction of the UI on a real machine or simulator
- You can add assertions during recording
- Generate Espresso unit test code, which can be done on the basis of the second development
In google samples of android-topeka example, to see how to record unit tests.
- Run-> Record Espresso Test
Click on the toolbar above, the terminal will appear in the selection window.
- In the real machine or run on the simulator
Select the terminal device to run well, the app will run, then you can start the UT recording.
- Start recording the UT
After the app is run, a recorded window will appear, showing the flow of UI interaction and the two buttons “Add Assertion” and “Complete Recording”. Next, start interacting, enter First Name and Last Initial, and select the picture, then the operation flow as shown below:
Click the OK icon in the lower right corner to enter the next screen.
- Add assertions
Click Add Assertion to add assertions during recording. Here, I added two assertions, one is to assert that the avatar region has been normal display, and the other is to assert the account area shows the text as “geniusmart T”.
- Complete the recording and generate the UT code
Click “Complete Recording” to complete the UT recording, and generate the code.
We can do this second development based on this code, write some tools can not help us to generate assertions.
- Multiplex UT
After the recording, the entire recording process will be in the form of code androidTest folder, we can repeatedly run UT, verify the accuracy of the code.
Espresso Test Recorder recording function and the second development, greatly improving the efficiency of writing Espresso UT. Even if you are not familiar with Espresso’s syntax, you can still write unit tests with higher coverage.
Also to be emphasized that, Espresso solved test View layer to MVP is, View layer depends on the Model layer and layer Presenter, the View layer if you need to initiate a network request, UT record is full of uncertainty, because you are not sure whether the normal response to network requests, and in response to what the result is, therefore requires additional layers of network requests and do some similar problems Mock or Fake.
Google is rewriting the project structure dialog box, used to resolve the project dependencies, and do a more friendly show.
- The Project Structure window opens
- View the dependencies that are updatable
In the Messages panel, you can view all dependencies within the application and automatically identify the local repository and / or the remote jCenter repository for newer versions. Through the “Update All” button to update all dependencies.
- View all dependencies and delivery dependencies
In the “Dependencies” panel, we can see all the Dependencies of the Module and pass dependencies, very convenient. In the past, we can only use the command line
gradlew dependencies to view dependencies.
Note: The screenshots in this section are from the “What’s new in Android development tools” theme of Google I / O, and in the latest version of the AS preview (either window or mac) 2.2 preview version of the introduction of the document did not formally introduce the function, so it is estimated that some time to experience.
Google in the development of Instant Run, in order to clarify the internal mechanism of the APK file, developed a new tool APK analyzer.
- Build-> Analyze APK
In the toolbar as above, select the apk file, you can view the apk analysis results, this section to chrome.apk example.
- View the file size
In the analysis results, you can view the original file size and download size, which can provide data for our apk thin support, to help us locate the file size can be optimized or deleted.
- View the resource file
In the res can view images and layout files.
- View the value table
Click on resources.arsc, you can view string, color, layout, etc. ID value.
- View the dex file
Click on the classes.dex file to see the number of methods declared and the number of methods referenced for each Java file.
View the merged sources for AndroidManifest.xml
App compiled, the list of documents will be much more than we write the code (such as the authority of the statement, the four components of the configuration, etc.), this part of the source code for a variety of dependent libraries.
The new version of the IDE provides the “Merged Manifest” feature to help us view the manifest file of the merger source.
The figure above, you can clearly see the network access by the
play-services-ads:8.4.0 dependency list provided by the library from the merger.
These small toys, especially the unit test recording and dependency management, are five-star praise, is very worthwhile in the project development practice. In addition, the 2.2 version also provides more friendly support for C + +, as well as visual layout blueprint mode, etc., look forward to the official version of the early arrival, but also look forward to Google for us to bring more and better and more fun new Features.