Recording and Performance testing Android applications with HP Loadrunner VuGen

上一篇 / 下一篇  2016-08-13 17:06:09 / 个人分类:LR

原文地址:http://www.perftesting.co.uk/recording-and-performance-testing-android-applications-with-hp-loadrunner-vugen/2011/11/14/?replytocom=485#respond

In this article I will show how to create a Loadrunner test to replicate the network traffic generated by an Android application. The Android SDK will be used to execute the application under test, while HP Loadrunner Virtual User Generator (VuGen) captures the network packets and translates it to Loadrunner virtual user script.

Prerequisites:

  • Loadrunner/Performance Center Virtual User Generator 9.5x
  • Android SDK with the Android emulator
  • A test application

Prepare the Android emulator

First, the Android SDK is to be downloaded. After unzipping the SDK, the SDK Manager.exe configures the SDK and downloads the available binaries for the different Android OS variants.

This will take a while. When done, an Android device is to be created. For this example an Android 2.2 device has been created with the name ’A22’.

Configure a new Android virtual image to host the application under test within the SDK Manager

Get the application under test ready

Have your Android installation package (.apk file) ready for installation.

For this example the Android SDK’s Wiktionary example will be used. As it is shipped without the built binaries, I used IntelliJ Idea Community Edition (which comes with built-in support of Android development) to build it. The source code of Wiktionary can be located in the Android SDK’s directory at: ….\android-sdk-windows\samples\android-13\Wiktionary\out\production\Wiktionary

Deploy the Android application into the emulator

Start the created virtual device, either from the SDK Manager user interface, or from command line (specify the appropriate device name instead of A22 if it was named differently):

1
D:\apps\android-sdk-windows\tools\emulator.exe -avd A22 -netspeed full -netdelay none ~/.android/A22.avd

[Update] Since I have written this article the emulator’s parameter list has been changed. Now you can start an emulator device by emulator.exe @DeviceName, e.g. based on our example emulator.exe @A22

Once the device has finished booting, deploy the build Android package (the APK file) into it with the adb tool in the Android SDK (execute it Viagra 100mg from the directory which contains the APK file):

1
D:\apps\android-sdk-windows\platform-tools\adb install Wiktionary.apk

Start the application in the emulator device, and ensure, that it works properly.

Capture the network traffic of the Andoid application with VuGen

Close the emulator window.

Create a new virtual user script. in Virtual User Generator. As Wiktionary uses HTTP and JSON, the http/WEB protocol will be used.

In the Start Recording dialog specify the executable of the Android emulator and the runtime parameters of the virtual device:

  • Program to record: D:\apps\android-sdk-windows\tools\emulator.exe
  • Program arguments: -avd A22 -netspeed full -netdelay none (see the [Update] on argument list above)

(specify the appropriate device name instead of A22 if it was named differently)

Before starting recording, the Network Capture level should be modified to „Socket level and WinInet level data”. (the other two options either do not record any traffic or crash the emulator during recording…)

Add the content-type “application/json” to Non-Resources. This will produce separated web_url calls for Json resources. Otherwise json calls might be placed into EXTRA_RES section.

Adding content types to 'non-resources' list in VuGen Recording options

Start recording and execute the steps of the test. Make sure, that the Recording toolbar shows recorded events.

After stopping the test the VuGen testscript. is generated. Here is a sample recording:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Action()
{
web_url("api.php",
"URL=http://en.wiktionary.org/w/api.php?action=query&list=random&format=json",
"TargetFrame=",
"Resource=1",
"RecContentType=application/json",
"Referer=",

TAG: Android Testing testing

 

评分:0

我来说两句