Test cases and workflow for in-app purchase of android app

 IAP Testing

In this blog, I would like to share android in-app product types, workflow of in-app purchases, and the set up of the test releases by a developer. These 3 things are essential for a tester to start in-app purchase testing.

In-App Product Types

The android in-app billing supports the managed in-app products and subscriptions.

Managed product: Once you purchase a product, that item cannot be purchased again until you consume the item, by sending consumption to Google play.

Subscriptions: This product type offers sell features, content, and services to users from the app with recurring weekly or monthly or annual billing.

In-app purchase workflow and settings for releasing apps to test:

The Google Play Console provides several tools to test the in-app billing. There are three stages of app deployment in android in-app purchase:

  1. Alpha
  2. Beta
  3. Production

Alpha and Beta Release (Sandbox account):

Publish app directly to Google Play’s alpha and beta release channels for testing purpose. The app will be available only to the tester who can download and install the app to the device from Play Store.

To release a test app, first, the developer should create and add test-user Gmail accounts to ‘Tester List’ group in Alpha/Beta release section.

Both the alpha/beta release is same; the only difference is adding the number of tester accounts.

  • Alpha test – we can create a small group of testers.
  • Beta test – we can create up to 50 lists per track and can add up to 2000 users in each track.

Testing in-app purchase (In-app billing – Subscription type)

To test in-app purchase, we need to publish the app to an Alpha or Beta channel in Google Play. You can choose any user to be a test account and any user of test account can make test purchases with any available payment methods, without any actual charges to their accounts.

First, the developer has to upload and publish in-app products in play console before publishing the APK itself. Then, add user account ID (Gmail ID) to License testing section in the developer console and we can add up to 400 test-user accounts to test in-app purchase products.

Steps to add: Login to developer console and Go to Settings –> Accounts details then add the addresses to License Testing field.

Note: The address should belong to Google account. It will not accept other accounts to add as license tester.

Once you add the users as license tester accounts and saved the changes, within 15 minutes those users can make a test purchase of your in-app products. After publishing the app, the tester needs to opt-in the alpha/beta release of the app using the provided opt-in URL before making test purchases. In this case, the developer will provide an opt-in link to the test users.

The opt-in URL will generate once the developer has created and added the license test users in the license section. Before that, the developer will send an invitation to users to become a part of tester group and then copy and send generated “opt-in URL” to all test-user accounts.

Once test-users get authorized test access, they can make a purchase without any actual charges. After all the processes have completed, the app will be available in tester’s Play Store who were all added as the Alpha/Beta tester.

Test purchase is auto-renewable on daily basis for any actual duration. The app will automatically renew every day until you cancel the purchase.

Important note: Licensed account must be on the user’s android device. If the device has more than one account, the purchase will be made with the account that downloaded the app. If none of the accounts have downloaded the app, the purchase is made with the first account. Users can confirm the account that is making a purchase by expanding the purchase dialog.

Steps to start an in-app purchase (Subscription) test:

  1. The user will receive an invitation to become an Alpha/Beta tester. Click on ‘Become a Tester’ button in the mail to be a part of the tester group.
  2. Later, the tester will get detailed mail along with opt-in URL link of test application from Google Play Console.
  3. Click on ‘opt-in URL.’ It will redirect to your Play Store app and shows test app with all the information.
  4. You can download and install the app to your phone from Play Store using licensed tester account.
  5. To add payment methods for purchasing the app, select Slider Menu in Google play store –> choose Account option –> Select Payment methods –>  then add your valid international Credit/Debit Card or Net banking detail along with your name and address.
  6. Click on Save in the popup window.
  7. The Payment method will be successfully saved. If you did not add your Payment method, it will ask the card details while doing the purchase.
  8. Once the payment details are successfully added, an amount of ₹50.00 will be debited from your account for Debit/Credit card verification but after few minutes, the amount will be credit back to your account. It will be debited while adding the card detail only. It will not debit while subscribing to the app (If you are a licensed test-user).
  9. Next, you can start testing subscription function in your app
  10. The following message will be displayed on Google popup when you make a payment. “This is test subscription. It will recur daily. You will not be charged.”
  11. You will get a receipt for your purchase order from Google Play Store on successful purchase.
  12. The subscription will auto-renew and send email every day until you unsubscribe the purchase.

Test Cases:

  1. Pricing info should be displayed based on region-specific currency and needs to verify whether the mentioned price has tax included or excluded.
  2. Span time of billing period and description about your subscription should be shown as per requirement.
  3. To verify, the app will deduct given price while purchasing the subscription.
  4. Services or Features should be accessible after successful purchase.
  5. Check whether the purchase auto-renews in the specified duration because it should be continuously renewing the purchase until you cancel the purchase.
  6. Check whether the subscription is expired once the specific subscription period is over. The subscription will expire only if the user canceled auto-renewal or subscription (Auto-renewable product).
  7. Check whether the app is expired on time and make sure that the users should not access purchasable content or features (Non-auto renewable product).
  8. Subscription features should be automatically restored while re-install/updating the app. If it is a Non-consumable product, the app should have restore button for restoring the purchases.
  9. Use the same purchase id to multiple devices and verify whether the app has subscribed state.
  10. Use different accounts (ID doesn’t have a subscription) to Google Play and install the app and verify that the app has Un-subscribed state.
  11. Subscription features should continue to users after canceling the auto-renewal or subscription and until it expires.
  12. Check the status of in-app purchase when users purchase while there is no network on the device. ‘No internet connection’ should be shown when the user tries to purchase a product and while accessing purchasable features.
  13. Once the network connection comes back, check the status of previously attempted purchase at that time of network failure.
  14. The app should validate the purchases on the update
  15. Check the subscribe function of product that was already purchased. It should not allow purchase again.
  16. Verify that the users get purchase receipt from Google play until they cancel the subscription.

 

FacebookTwitterGoogle+Share
Performance Test of Web Application using Apache JMeter

Apache JMeter is one of the best open source tools for Load and Performance testing. It can be widely used for a variety of applications. In this blog, I would like to share how to do the performance and load testing of a web application using JMeter Recording Tests (GUI mode) on Windows Operating System. Before that, I would like to share about Apache JMeter features and installation process.

Apache JMeter Features:

  1. It has the ability to load and performance test many different applications, server, and protocol types such us HTTP, HTTPS, FTP, TCP, Web Services, etc.
  2. It allows to recording scripts, building, and debugging.
  3. It has compatibility with Windows, Linux, Mac OS, etc.
  4. Complete portability and 100% Java purity.

Downloading and Running Apache JMeter:

Requirements:

JMeter is a pure java application. It requires the system that is compatible with java and a fully compliant JVM 7 or higher version. Download and install Java Development Kit (JDK 7 or higher) from here.

Downloading JMeter:

  1. Download the latest version of Apache JMeter x.x from here.
  2. Choose Binaries file and either zip or tag file to download the JMeter

Configure JMeter

Running JMeter:

There are three modes to start JMeter

GUI Mode: It can be used for recording test script and running their script to JMeter itself. Run the Jmeter.bat file for Windows system and JMeter file for Linux. These files are found in the bin folder. After that, JMeter GUI will appear.

Command Line Mode (Non-GUI): For load testing, use this mode to get optimal results.

Server Mode: For distributed testing, use this mode to run JMeter in Sever on the remote node and control the servers from GUI.

Test Script Recording of Web Applications

Steps to Configure JMeter:

#1. Go to apache-jmeter-3.1/bin folder and start the jmeter.bat (Batch) file.

Jmeter configuration

#2. Select “Test plan” on the Tree

JMeter Proxy

#3. Right click on Test Plan and go to Add > Threads (Users) > Thread Group

Once Thread Group is added, configure the JMeter.

Jmeter configuration

Above figure shows JMeter configuration for 10 users, 5 seconds ramp-up and 1 Loop count.

Number of Threads: The number of users going to hit the server. Ramp-Up Period: Time given for each user to hit the server. For Example:

  • 100 users, 50 seconds ramp-up – start with 1 user, each second 2 users added
  • 100 users, 100 seconds ramp-up – start with 1 user, each second 1 user added

Loop count: Execute the same process ‘N’ number of times continuously and increase the loop count value.

#4. Right click on Thread Group and go to: Add > Config Element > HTTP Request Defaults

Configure JMeter

Add the following three things to this window.

Server Name or IP: Server Name or IP is nothing but URL of the website on which you have to perform the load test.

Port Number: Add the default port number 8080 to the Port Number field. To change the number, edit it under Global settings.

Protocol: Here you can mention your required Protocol, http or https. Don’t mention as in Caps.

#5. Right click on Thread Group and go to Add > Logic Controller > Recording Controller

JMeter Proxy

You can watch recorded samples of your actions while you are browsing the web applications. Each Https request will be recorded.

#6. Right click on Thread Group and go to Add > Config Element > HTTP Cookie Manager

To use cookies on your web application, add HTTP Cookie Manager to the Thread group. Test Script Recorder #7. Next, select Workbench. Right click on Workbench and add the Recorder: Add > Non Test Elements > HTPP(S) Test Script Recorder

JMeter Proxy

Check whether the port 8080 is open or busy in your system. If it is busy, you should change to the other port number that is always open in your system. On HTTP(s) Test Script Recorder, click the Add button in “URL Patterns Include.” Enter “*”. It has to record everything.

To restrict any image types and web pages while recording the scripts, we need to enter the pattern in “URL Patterns Exclude” which is not being recorded in JMeter.

Example patterns: .*\.png .*\.html .*\.jpg

#8. Right click on “HTTP(S) Test Script Recorder” and Listener: Add > Listener > View Results in Tree.

JMeter Proxy

We need to add at least one Listener in the workbench so that we could see results of JMeter while recording. In JMeter, there are many listeners to view results. We can generate the report in Graph or Table.

Add Listeners: Right click on “Recording Controller” > Add > Listener > View Results in Table. Right click on “Recording Controller” > Add > Listener > Summary Report. Right click on “Recording Controller” > Add > Listener > Graph Results.

#9. Finally, click the “Start” button in the Script recorder window. Then the JMeter Proxy server will start on your system. When the JMeter starts, ApacheJMeterTemporaryRootCA.crt certificate will be created in the bin directory. Click OK and continue.

JMeter

Configure JMeter


Configure Browser to use the JMeter Proxy:

We will use Firefox to test the application. For this, we need to do the following proxy setup in the browser.

Steps to Configure Mozilla Firefox with JMeter Proxy:

  1. Open the browser. At that time, don’t close the JMeter window.
  2. Click Menu button from the Navigation bar.
  3. Choose “Options” menu.
  4. Click “Advanced” tab on the left and then select “Network” tab.
  5. Click on “Settings” button in the Connection section.
  6. Choose “Manual Proxy Configuration.”
  7. Type HTTP Proxy as localhost or enter IP Address of your system and then set port as 8080 (Check whether this port is free. If not change the port)
  8. Check “Use this proxy server for all protocols” option.
  9. Click “OK” button
  10. Click “OK” button again.

Now your browser is configured with JMeter Proxy server. Refer the below image to configure the Firefox browser.

JMeter Proxy

Now everything is configured and ready to start recording the user actions in JMeter.

Record the Script:

Before starting the recording, ensure that JMeter was started in your system.

  1. Open Firefox browser and type the URL of your application then hit enter.
  2. Do the actions whatever you want to test in the application.
  3. Now go to JMeter and click “Recording Controller” in the Thread Group. Here you can see the script for whatever actions you did in the browser.

X Configure JMeter

          4. Once you are done with the actions in the browser, click on “Stop” button of the HTTP(S) Test Script Recorder window in JMeter.

Run the Script:

We are ready to run the recorded script. Save the test plan. Run the Test Plan:  Press Ctrl + R (or) Click “Start” button.

While running the script, at the top right corner, a green color square box will display. Once it is completed, the box will change to Grey.

 JMeter Proxy

View Results:

Click on “View Results” in Tree under the Recording Controller.

Jmeter

Click on View Results in Table.

Configure JMeter

Click on Aggregate Graph > Graph

JMeter Proxy

Click on Summary Report.

Configuring JMeter

In JMeter, we have to save recorded scripts in different formats like JMX, CSV, etc. We can upload the recorded script files to third party online load testing tools and get detailed and optimal results from there.

Online tools for load testing:

  1. Blaze meter  -> https://www.blazemeter.com
  2. Redline13  -> https://www.redline13.com
How to Test Native App Performance using Apache JMeter?

In my previous blog, I have elucidated how to test web application’s performance using JMeter. Here, I would like to share how to test mobile app’s performance in JMeter.

JMeter records mobile application requests on HTTP(S) Script Recorder and it has features to prepare and run our mobile application performance test scripts. All we have to do is to configure JMeter and Mobile device. In JMeter, we can test both iOS and Android native applications.

Steps to Configure JMeter:

  1. Go to apache-jmeter-3.1/bin folder and start the jmeter.bat (Batch) file.
  2. Right click on “Test Plan” > Add > Threads User(s) > Thread Group.
  3. Right click on “Thread Group” > Add > Logic Controller > Recording Controller.
  4. Right click on “Thread Group” > Add > Listeners > View Results in Tree.
  5. Add HTTP(s) Script Recorder to Workbench by selecting Workbench > Add > Non-Test Elements > HTTP(s) Script Recorder option.
  6. Add Port value as 8080 and click “START” button in script recorder. The JMeter proxy will be started on localhost.

Next, we need to configure the mobile device as per the following steps.

iOS Device Proxy Configuration:

  1. Go to Settings > Wi-Fi option. (Note: Network should be same for both Mobile and Laptop/Desktop).
  2. Click on the Connected network.
  3. Select “Manual” option from HTTP Proxy.
  4. Set ‘Server value as system IP address and Port value to 8080 as per JMeter setup.
  5. Now start the application on the device and its each request will be recorded in JMeter.

 Android Jmeter

Android Device Proxy Configuration:

#1. Go to Settings > Wi-Fi option.

#2. Press and hold on connected network and Click ‘Modify Network’ option.

#3. This will open advanced settings from where we can modify Proxy.

#4. Change the Proxy to Manual.

Apache JMeter

#5. Set Hostname value as system IP address and Port value to 8080 as per JMeter setup.

Android PAC

#6. Click on ‘Save’.

#7. Now start the application on the device and its each request will be recorded in JMeter.

#8. Before running the application, make sure that HTTP(S) script recorder was started in JMeter.

#9. Once the application is started, the actions of the script will be recorded under “Recording Controller.”

#10. Once actions are done in the application, stop the script recording by clicking ‘Stop’ button in HTTP(S) script recorder screen.

#11. Now, expand the “Recording Controller” in JMeter. You can view all the Recorded scripts of whatever actions are done in the applications.

#12. Finally, click the ‘Play’ button. It will run recorded scripts as per your Threads setup.

#13. Click on “View Results in Tree”. Here you will see the result of your script.

 

Solutions for issues while testing the mobile application:

Here are the solutions for the issues that we have noticed while doing the load test in JMeter.

Issue 1

The application wasn’t getting loaded.

Solution

The issue is caused because our system was enabled with the firewall protection in security software. This is restricting network connection when setup with the proxy. We have disabled the firewall protection in antivirus settings.

Issue 2

Internet was not working with Proxy on the mobile device when we configure the mobile device and JMeter.

Solution

The reason might be that the system IP address is not configured with JMeter properties which mean the current IP address is not added to the JMeter properties file. We have added remote host IP address to property file as per the following steps.

  1. Open the browser and type IP address and Port number that is mentioned in JMeter to check whether it was configured. If browser shows Connect, then it is working fine otherwise if it is continuously loading, then it was not configured. Then we have to follow the below steps:
  2. Open apache-jmeter folder from the local drive and go to the bin folder.
  3. Open “jmeter (.properties)” file and find “Remote hosts and RMI configuration” section on this file.
  4. Under this section, add the system IP to remote hosts with comma delimited and save the file.