As mobile app usage increases, load testing mobile apps is becoming a key part of the software development lifecycle to make sure your application is ready for traffic. If your mobile app interacts with your application server via REST or SOAP API calls, then LoadStorm PRO can load test mobile app servers like yours.

LoadStorm PRO uses HTTP archive (HAR) recordings to simulate traffic, and we normally create these recordings using a browser’s developer tools on the network tab to record all requests sent to the target server. In this article, I’m going to introduce you to two ways to make recordings of user traffic that can be used in LoadStorm. The first involves packet capturing from your mobile device, and the second involves a Chrome app called Postman used in combination with the Chrome developer tools.

Simulate traffic by using Packet Capturing

If you like to keep things simple, then this method should save you the trouble of manually creating requests as shown in the next method. You’ll need a packet capturing mobile app (such as tPacketCapture) that stores requests in the PCAP file format, and allows you to share the PCAP file. The PCAP file generated by the app can then be converted to a HAR file to be uploaded into LoadStorm for use in a load test. To do this, you can use PCAP Web Performance Analyzer for free without needing any setup, or you can install your own converter from the pcap2har project on GitHub.

For Android devices, this method works as follows:

  1. Install tPacketCapture or other mobile app for capturing packets.
  2. Close any other apps that you have running to avoid unnecessary packets.
  3. Open the packet capturing app and click the Capture button.
  4. Open the mobile app you wish to record, and begin emulating user behavior.
  5. When you’re done emulating user behavior, swipe your notifications area open to click the “VPN is activated by tPack..” message.
  6. Click the Disconnect button to stop capturing packets.
  7. Switch back to the tPacketCapture app to open the File list tab.
  8. Select the PCAP file you just created, and share it using email (or method of your choice).
  9. Convert the PCAP into a HAR using the PCAP Web Performance Analyzer, or your own pcap2har converter.
    Note: If you use the PCAP Web Performance Analyzer you should uncheck the Remove cookies option.
  10. Upload the HAR to LoadStorm PRO.

Click to Zoom

For iOS devices:

At this time, packet capturing mobile apps are only offered on Android devices. Apple products do not support direct packet capture services. However, if you connect your iOS device to a Mac via USB then you can use OS X supported software (such as Cocoa Packet Analyzer) to capture the packets, as described on the Apple developer site.

Record requests made in Postman using Chrome developer tools

To make a recording with the Postman app, follow these steps:

  1. From the Chrome Web Store, you can install Postman by rickreation, and the Postman launcher.
  2. Click the Postman launcher icon at the top-right of the browser.
  3. Open the developer tools by right-clicking the page you’re on, and selecting Inspect Element.
  4. Switch to the Network tab in the developer tools and check the Preserve log box.
  5. Create your GET or POST request.
  6. Click the Send button and observe the POST request in your developer tools.
    Note: Extra requests generated by Postman won’t appear in LoadStorm.
  7. Repeat steps 5 and 6 as needed to mimic user behavior.
  8. Right-click in the network log and choose Save as HAR with Content.
  9. Upload the HAR to LoadStorm PRO.

Click to Zoom

REST

Making RESTful GET or POST requests will rely heavily on your knowledge of how your mobile app interacts with the application server. If you have a network log that shows the incoming requests from the mobile application, that can help simplify the reconstruction of those requests in the Postman app. Postman actually offers 11 methods for interacting with an application server, and of these we’ll typically only need to use GET and POST requests:

  • GET – For a RESTful request to interact via a GET request you’ll usually need to include some parameter(s) as a query string that tells the application server what you would like returned. For example, you could request to see your all of your tweets on your twitter timeline.
  • POST – POSTs are used to give the target application new information like adding a tweet to your twitter account from your phone. The content that you would like to POST is sent via the request payload in one of three options; form-data used for multi-part forms, x-www-form-urlencoded used for standard forms, and raw used for a variety of content (JSON, XML, etc.).

In some cases you will also need to add some form of authorization token in the request headers to let the application server know you have the rights to GET or POST information. Postman offers a few options to assist with authorization settings (i.e. Basic Auth, Digest, and OAuth 1.0), but you can always manually input the authorization header if you know the name of the header, the value, and format to send it in.

SOAP

Even though Postman is primarily designed to work with RESTful API calls, it can also work with SOAP.

To make SOAP requests follow these steps:

  1. Change the method to POST.
  2. Select the raw option for content type.
  3. Set the raw format to “text/xml”.
  4. Manually add the SOAP envelope, header, and body tags as required.
  5. Send requests as needed.

Click to Zoom

Additional information about creating SOAP requests can be found on the Postman blog.

Video Tutorial

This video is a short guide on recording a HAR using Postman in combination with the Chrome developer tools.

Also check out Ruairi Browne’s Postman tutorial covering RESTful API GETs and POSTs to Twitter as well as OAuth1.0 credentials.


Upload a Recording

To load test a mobile application using LoadStorm PRO, a HAR recording must be made to simulate the traffic. Once you’ve decided on a recording method, all you have to do is upload your HAR file into LoadStorm, and you’ll be on your way to load testing your app and ensuring end-user satisfaction. If you have questions or need assistance, please contact support@loadstorm.com, visit our learning center, or leave a comment below.

Sources:

Facebooktwitterredditpinterestlinkedinmail