Sunday, 9 February 2014

Installing Ruby and Watir on Windows 7

I recently started playing around with Web Application Testing in Ruby or Watir for short. As is recommended I downloaded the Homebrewer's Guide to Watir by Zeljko Filipin and started trying to install the latest versions of the RubyInstaller for Windows (currently 2.0.0) when I ran into a few problems. (Random tangent: I like the idea of using Leanpub to create and modify install documents for open source applications.)

I installed Ruby and Watir on a Windows 7 64 bit machine using the 32 bit versions and everything seems to work fine so far. Here's how I installed everything using the RubyInstaller and instructions from the guide above (note some of these instructions will be a duplicate of the guide):

Ruby Installation
  1. Open a command prompt (Run and type cmd) and type ruby -v to see if you have Ruby installed (if you don't it will say the command isn't recognized) and the version number. 
  2. I have Windows 7 64 bit but I use the 32 bit installers from RubyInstaller Downloads including:
    1. Ruby 2.0.0-p247
    2. DevKit-mingw64-32-4.7.2
  3. Run the Ruby installer and on the optional tasks page select the below items before completeing:
    1. Add Ruby executables to your PATH
    2. Associate .rb and .rbw files with this Ruby installation
  4. Open a new command prompt and type ruby -v to see if Ruby installed and the version number. 
  5. (Optional) Once installed you can update the RubyGems distributed with the installer by typinggem update --system and watching for the "RubyGems system software updated" to know when its complete. 
  6. Move on to the DevKit installation. 
DevKit Installation
  1. Run the DevKit installer but change the extraction folder to C:\devkit
  2. Open a command prompt (Run and type cmd) and change the folder to C:\devkit (use the command cd c:\devkit).
  3. Run the command ruby dk.rb init. If this step is successful you'll see a response like "[INFO] found RubyInstaller v2.0.0 at C:/Ruby200".
  4. Run the command ruby dk.rb install. If this step is successful you'll see a response like "[INFO] Installing 'C:/Ruby200/lib/ruby/site_ruby/2.0.0/rubygems/defaults/operating_system.rb'" and "[INFO] Installing 'C:/Ruby200/lib/ruby/site_ruby/devkit.rb'"
  5. Move on to Watir installation.
Watir Installation
This is where I ran into problems with the 2.0.0 version of Watir. Something about the mini_magick version erroring out. To prevent this problem we do:
  1. Run the command (still from the C:\devkit command window) gem install mini_magick -v 3.5.0 which works around the version problem. You should get a response like "2 gems installed"
  2. Then run the command gem install watir --no-ri --no-rdoc to install the rest of Watir. You should get a response like "Successfully installed watir-4.0.2-x86-mingw32 and 23 gems installed". 
Check the installation
In the same command window type (after each line of code submit the commands)

  1. irb
  2. require "watir"
  3. browser = Watir::Browser.new
  4. browser.goto "google.com"
If all is setup correctly you should get your default browser to open a new window and then browse to Google. Good luck.

Tuesday, 24 December 2013

Ubantu Dual boot Installation

Ubuntu Dual Boot Installer is provided as a tech preview for developers who want to run Ubuntu and Android on a single device. It is not intended to be used by regular users, neither at this point nor as its ultimate goal. Those developers installing it should be familiar with the Ubuntu and Android partition layouts and should also feel at home with manually flashing partitions in case something goes wrong.
Ubuntu Dual Boot Installer was born as an internal skunkworks project some Canonical Engineers dedicated a limited amount of their time to. Seeing the good progress, it was decided to release this preview for the developer community to test, study and contribute to.
Dual boot is not part of the regular Ubuntu release.

What to expect after installation

  • A single device with the ability to switch between fully functional Android and Ubuntu images
  • On Android: an Ubuntu Installer app to install Ubuntu, as well as to boot into Ubuntu
  • On Android: the SuperUser app to grant permissions to the Ubuntu Installer app
  • On Ubuntu: an Ubuntu Dual Boot app to boot into Android
  • Ubuntu system updates are not yet supported from the Ubuntu side, but they can be done via the Android app

Requirements

To install dual-boot, you'll need:

Step 1 - Desktop Setup


The following steps are required on your desktop system that you'll need in order to flash and communicate with the device.

Set up the Touch Developer Preview Tools PPA


The PPA has the tools and dependencies to support Precise, Quantal, Raring and Saucy. Add the Ubuntu Touch PPA by adding the following custom source list entry to your /etc/apt/sources.list file.
On your computer, press Ctrl+Alt+T to start a terminal.
sudo add-apt-repository ppa:phablet-team/tools

Then do the following:
sudo apt-get update
sudo apt-get install phablet-tools android-tools-adb android-tools-fastboot

Step 1.5 - Optional Android Backup


  • If not enabled, enable developer mode, by tapping Settings -> About phone -> Build number (x 7 times)
  • If not enabled, enable usb debugging in Settings -> Developer options -> USB debugging
  • Execute on your computer $ adb backup -apk -shared -all
This should hopefully create backup.ab with all of your apps, OS, and data. Later, after reflashing with android (or rooting / unlocking) you will be able to use $ adb restore backup.ab to restore all of your data.

Step 2 - Device unlock


If the device is already unlocked, skip to Step 3. These steps will wipe all personal data from the device.
  1. With the device powered off, power on the device by holding the Power button + volume up + volume down.
  2. The device will boot into the bootloader.
  3. Plug the device into the computer via the USB cable.
  4. On your computer, press Ctrl+Alt+T to start a terminal. Type sudo fastboot oem unlock, followed by Enter
  5. On the device screen, accept the terms of unlocking.
  6. Boot the device by pressing the power button (pointed by an arrow with Start on the screen).

Device factory reset


If you get stuck in a bootloop rebooting the tablet after unlocking the bootloader... Here's what you do:
  1. During the bootloop.. hold the power button + volume up + volume down button simultaneously to get yourself back into fastboot mode as you were previously.
  2. In fastboot mode.. use the volume keys to scroll to Recovery and the power button to select it.
  3. In Recovery (Android robot on his back with a red triangle)... tap the volume up button and the power button simultaneously which will bring you into stock recovery. Again.. Don't hold the buttons, just tap them simultaneously. Also make sure you're holding the correct volume button. Up will be the volume key on the right.
  4. Once you're in Recovery.. perform a factory reset/data wipe and then reboot your tablet... you should now be back to the Welcome Screen.

Step 3 - Initial Device Setup


Follow these initial steps on your device:
  1. If not booted, boot the device into Android
  2. Enable USB debugging on the device
    • on Ice Cream Sandwich (version 4.0) go to Settings and turn on USB Debugging (Settings > System > Developer options > USB debugging).
    • on Jelly Bean (versions 4.1 and 4.2) you need to enter Settings, About [Phone|Tablet] and tap the Build number 7 times to see the Developer Options.
    • on 4.2.2, (settings > about > tap on build number 7 times to activate the developer options menu item).
    • On either Android version you must then enable USB debugging via Settings > Developer options > USB debugging. You will also need to accept a host key on the device.
      • On the workstation-> adb kill-server; adb start-server
  3. Plug the device into the computer via the USB cable.
    • Depending on the installed Android version, a popup will show up on the device with the host key that needs to be accepted for the device to communicate with the workstation.
    • Note, 'adb devices' should not show the device as 'offline'. If it does, unplug the device, run adb under sudo on the workstation (sudo adb kill-server; sudo adb start-server), then plug the device back in.
    • In some cases, the device will continue to show offline, and the host key popup will not appear if the USB connection method is 'MTP' (default for some devices and versions of Android). Unchecking all options in the USB connection method (Settings -> Storage -> Menu -> USB computer connection -> MTP, PTP) seems to resolve this adb connection issue for some users.
  4. Save the version of the current image on the device, if on Android, to use as a reference to revert back to. The version can be found by going to Settings > About Phone > Build Number.
Newer Nexus 10s have not booted fully after developer mode was enabled. If this occurs boot into the bootloader and do "fastboot -w", then proceed to the next step.

Dual boot installation instructions

Installing the Ubuntu Installer app in Android

  1. On your computer, download the dual boot installation script into your home directory from: http://humpolec.ubuntu.com/latest/dualboot.sh
  2. Open a terminal on your computer pressing the Ctrl+Alt+T key combination
  3. Make the installation script executable by running this command:
    chmod +x dualboot.sh
  4. Ensure that your device:
    • has booted normally into the Android user interface
    • has USB debugging enabled
    • has an unlocked bootloader
  5. Connect your device via USB to your computer
  6. Install dual-boot by running one of these commands on a terminal:
    • If it's the first-time dual-boot installation and you are using stock Android or AOSP firmware without the SuperUser app, run this command:
      ./dualboot.sh FULL
    • Alternatively, to update only the Ubuntu Installer Application or if you are running non-stock Android firmware (e.g. CyanogenMod), run this command:
      ./dualboot.sh UPDATE
After installation, the phone will reboot several times. Once finished, it will boot into Android and you will find the dual boot app as “Ubuntu Installer” in the Apps section.
Now follow the instructions below to install Ubuntu from Android.

Installing Ubuntu from Android

Note: 2.7GB of free memory space is required on your device for the Ubuntu installation.
  1. Optionally, on your desktop, and while your device is still connected via USB, issue the following command on the terminal to free up space (say "Yes" if you are asked to grant permissions on the device):
    adb shell "su sh rm -rf /cache/*"
  2. On the device, press the apps button in Android to bring up the list of apps
  3. Browse the apps to find the Ubuntu Installer icon and press it to start the app
  4. When the app launches, press on Choose channel to install and choose a channel to download from (the recommended channel is Trusty)
  5. Once download is completed you need to Grant SU permissions to the application for the install to be successful. Press the Grant button, when prompted.
  6. Press the Reboot to Ubuntu button to boot to Ubuntu.
  7. A standard phone reboot with the hard key will always boot to Android.
Notes:
  • All channels supported by the phablet-flash tool are also supported by the Ubuntu Installer on Android
  • When selecting an Ubuntu channel, the bootstrap checkbox lets you wipe user data from Ubuntu, otherwise it is kept between installations. Since you're installing for the first time now, it won't make a difference
  • When selecting an Ubuntu channel, unticking the latest version checkbox will let you select a particular image number. Otherwise, if checked it will default to the latest image.
  • If during installation the Ubuntu download finished while the phone was locked or when the Ubuntu Installer app was not on the foreground, the installation button will change to Resume install. This will resume installation to the point where SuperUser permissions are requested.

Additional notes

Updating to a new Ubuntu image

Because Dual Boot is a special set-up the standard update method for Ubuntu currently does not work (see Feature Roadmap).
To update Ubuntu to a newer version, On the android Ubuntu dual boot application, select "Uninstall Ubuntu" from the menu options. Next you will be asked if you want to keep the user data from Ubuntu. If you do not select "Delete user data", the next installation of Ubuntu will preserve your contacts, installed applications, pictures, background settings, ...
Once Ubuntu has been uninstalled, follow the same installation step to download a newer version of Ubuntu.

Getting phone calls to work in Ubuntu and Android 4.4

The radio image shipped with Android 4.4 is reused on the Ubuntu side to make phone calls or use WiFi or sound, and it is not yet supported in Ubuntu. Until Ubuntu gains support for the Android 4.4 radio, there is an easy workaround whereby an older radio firmware can be flashed in the modem partition. You can do this either before or after installing dual boot
Follow these steps to downgrade the radio firmware and get Ubuntu calls to work:
  1. Download an Android 4.3 firmware for your device onto your PC. Follow the links on this table >
  2. Open a terminal with Ctrl+Alt+T
  3. Extract the firmware tarball and cd to its directory.
  4. Run the following command to reboot into the bootloader
    adb reboot bootloader
  5. Once in the bootloader, run this command to reflash the radio. Replace $RADIO_FIRMWARE by the name of the file containing the radio firmware for your device (it's easily recognizable, as it starts with radio-$DEVICECODENAME):
    fastboot flash radio $RADIO_FIRMWARE.img
  6. After flashing, reboot and phone calls should work in Ubuntu:
    fastboot reboot

If something goes wrong

If something goes wrong after the dual boot installation and you cannot boot either into Ubuntu or Android, you can revert the Android installation to the status it was before dual boot by reflashing the original boot and recovery images. Only the recovery partition is actually modified by dual boot, but you can choose to reflash the boot partition just in case.

  1. Download the Android firmware you are running on your device onto your PC.
  2. Open a terminal with Ctrl+Alt+T
  3. Extract the firmware tarball and cd to its directory.
  4. Run the following command to reboot into the bootloader
    adb reboot bootloader
  5. Once in the bootloader, run this command to reflash the boot partition:
    fastboot flash boot boot.img
  6. Without exiting the bootloader, run this command to reflash the recovery partition:
    fastboot flash recovery recovery.img
  7. After flashing, reboot and your phone should start into Android:
        fastboot reboot

Thursday, 5 December 2013

Mobile app testing - Complete Guide

All of the following testing types may be performed depending on your mobile testing requirements:
  • Functional testing
  • Performance testing
  • Security testing
  • Usability testing
  • Compatibility testing
  • Recoverability Testing

Functional testing:


The functional testing of Mobiles normally consists in the areas of testing user interactions as well as testing the transactions. The various factors which are relevant in functional testing are
  1. Type of application based upon the business functionality usages (banking, gaming, social or business)
  2. Target audience type (consumer, enterprise, education)
  3. Distribution channel which is used to spread the application (e.g. Apple App Store, Google play, direct distribution)
The most fundamental test scenarios in the functional testing can be considered as :
  1. To validate whether all the required mandatory fields are working as required.
  2. To validate that the mandatory fields are displayed in the screen in a distinctive way than the non-mandatory fields.
  3. To validate whether the application works as per as requirement whenever the application starts/stops.
  4. To validate whether the application goes into minimized mode whenever there is an incoming phone call. In order to validate the same we need to use a second phone, to call the device.
  5. To validate whether the phone is able to store, process and receive SMS whenever the app is running. In order to validate the same we need to use a second phone to send sms to the device which is being tested and where the application under test is currently running.
  6. To validate that the device is able to perform required multitasking requirements whenever it is necessary to do so.
  7. To validate that the application allows necessary social network options such as sharing, posting and navigation etc.
  8. To validate that the application supports any payment gateway transaction such as Visa, Mastercard, Paypal etc as required by the application.
  9. To validate that the page scrolling scenarios are being enabled in the application as necessary.
  10. To validate that the navigation between relevant modules in the application are as per the requirement.
  11. To validate that the truncation errors are absolutely to an affordable limit.
  12. To validate that the user receives an appropriate error message like “Network error. Please try after some time” whenever there is any network error.
  13. To validate that the installed application enables other applications to perform satisfactorily, and it does not eat into the memory of the other applications.
  14. To validate that the application resumes at the last operation in case of a hard reboot or system crash.
  15. To validate whether the installation of the application can be done smoothly provided the user has the necessary resources and it does not lead to any significant errors.
  16. To validate that the application performs auto start facility according to the requirements.
  17. To validate whether the application performs according to the requirement in all versions of Mobile that is 2g, 3g and 4g.
  18. To perform regression testing to uncover new software bugs in existing areas of a system after changes have been made to them. Also rerun previously performed tests to determine that the program behavior has not changed due to the changes.
  19. To validate whether the application provides an available user guide for those who are not familiar to the app

Performance testing:

This type of testing’s fundamental objective is to ensure that the application performs acceptably under certain performance requirements such as access by a huge number of users or the removal of a key infrastructure part like a database server.
The general test scenarios for performance testing in a Mobile application are:
  1. To determine whether the application performs as per the requirement under different load conditions.
  2. To determine whether the current network coverage is able to support the application at peak, average and minimum user levels.
  3. To determine whether the existing client-server configuration setup provides the required optimum performance level.
  4. To identify the various application and infrastructure bottlenecks which prevent the application to perform at the required acceptability levels.
  5. To validate whether the response time of the application is as per as the requirements.
  6. To evaluate product and/or hardware to determine if it can handle projected load volumes.
  7. To evaluate whether the battery life can support the application to perform under projected load volumes.
  8. To validate application performance when network is changed to WIFI from 2G/3G or vice versa.
  9. To validate each of the required the CPU cycle is optimization
  10. To validate that the battery consumption, memory leaks, resources like GPS, Camera performance is well within required guidelines.
  11. To validate the application longevity whenever the user load is rigorous.
  12. To validate the network performance while moving around with the device.
  13. To validate the application performance when only intermittent phases of connectivity is required.

Security testing:

The fundamental objective of security testing is to ensure that the application’s data and networking security requirements are met as per guidelines.
The following are the most crucial areas for checking the security of Mobile applications.
  1. To validate that the application is able to withstand any brute force attack which is an automated process of trial and error used to guess a person’s username, password or credit-card number.
  2. To validate whether an application is not permitting an attacker to access sensitive content or functionality without proper authentication.
  3. To validate that the application has a strong password protection system and it does not permit an attacker to obtain, change or recover another user’s password.
  4. To validate that the application does not suffer from insufficient session expiration.
  5. To identify the dynamic dependencies and take measures to prevent any attacker for accessing these vulnerabilities.
  6. To prevent from SQL injection related attacks.
  7. To identify and recover from any unmanaged code scenarios.
  8. To ensure whether the certificates are validated, does the application implement Certificate Pinning or not.
  9. To protect the application and the network from the denial of service attacks.
  10. To analyze the data storage and data validation requirements.
  11. To enable the session management for preventing unauthorized users to access unsolicited information.
  12. To check if any cryptography code is broken and ensure that it is repaired.
  13. To validate whether the business logic implementation is secured and not vulnerable to any attack from outside.
  14. To analyze file system interactions, determine any vulnerability and correct these problems.
  15. To validate the protocol handlers for example trying to reconfigure the default landing page for the application using a malicious iframe.
  16. To protect against malicious client side injections.
  17. To protect against malicious runtime injections.
  18. To investigate file caching and prevent any malicious possibilities from the same.
  19. To prevent from insecure data storage in the keyboard cache of the applications.
  20. To investigate cookies and preventing any malicious deeds from the cookies.
  21. To provide regular audits for data protection analysis.
  22. Investigate custom created files and preventing any malicious deeds from the custom created files.
  23. To prevent from buffer overflows and memory corruption cases.
  24. To analyze different data streams and preventing any vulnerabilities from these.

Usability testing:

The usability testing process of the Mobile application is performed to have a quick and easy step application with less functionality than a slow and difficult application with many features. The main objective is to ensure that we end up having an easy-to-use, intuitive and similar to industry-accepted interfaces which are widely used.
  1. To ensure that the buttons should have the required size and be suitable to big fingers.
  2. To ensure that the buttons are placed in the same section of the screen to avoid confusion to the end users.
  3. To ensure that the icons are natural and consistent with the application.
  4. To ensure that the buttons, which have the same function should also have the same color.
  5. To ensure that the validation for the tapping zoom-in and zoom-out facilities should be enabled.
  6. To ensure that the keyboard input can be minimized in an appropriate manner.
  7. To ensure that the application provides a method for going back or undoing an action, on touching the wrong item, within an acceptable duration.
  8. To ensure that the contextual menus are not overloaded because it has to be used quickly.
  9. To ensure that the text is kept simple and clear to be visible to the users.
  10. To ensure that the short sentences and paragraphs are readable to the end users.
  11. To ensure that the font size is big enough to be readable and not too big or too small.
  12. To validate the application prompts the user whenever the user starts downloading a large amount of data which may be not conducive for the application performance.
  13. To validate that the closing of the application is performed from different states and verify if it re-opens in the same state.
  14. To ensure that all strings are converted into appropriate languages whenever a language translation facility is available.
  15. To ensure that the application items are always synchronized according to the user actions.
  16. To ensure that the end user is provided with a user manual which helps the end user to understand and operate the application who may be not familiar with the application’s proceedings
Usability testing is normally performed by manual users since only human beings can understand the sensibility and comfort ability of the other users.

Compatibility testing:

Compatibility testing on mobile devices is performed to ensure that since mobile devices have different size, resolution, screen, version and hardware so the application should be tested across all the devices to ensure that the application works as desired.
The following are the most prominent areas for compatibility testing.
  1. To validate that the user Interface of the application is as per the screen size of the device, no text/control is partially invisible or inaccessible.
  2. To ensure that the text is readable for all users for the application.
  3. To ensure that the call/alarm functionality is enabled whenever the application is running. The application is minimized or suspended on the event of a call and then whenever the call stops the application is resumed.

Recoverability Testing

  1. Crash recovery and transaction interruptions
  2. Validation of the effective application recovery situation post unexpected interruption/crash scenarios.
  3. Verification of how the application handles a transaction during a power failure (i.e. Battery dies or a sudden manual shutdown of the device)
  4. The validation of the process where the connection is suspended, the system needs to re-establish for recovering the data directly affected by the suspended connection.
Other Important Checks:
  1. Installation testing (whether the application can be installed in a reasonable amount of time and with required criterion)
  2. Uninstallation testing (whether the application can be uninstalled in a reasonable amount of time and with required criterion)
  3. Network test cases (validation of whether the network is performing under required load or not, whether the network is able to support all the necessary applications during the testing procedures)
  4. Check Unmapped keys
  5. Check application splash screen
  6. Continued keypad entry during interrupts and other times like network issues
  7. Methods which deal with exiting the application
  8. Charger effect while an application is running in the background
  9. Low battery and high performance demand
  10. Removal of battery while an application is being performed
  11. Consumption of battery by application
  12. Check Application side effects

Source: Read more at http://www.guru99.com/testing-mobile-apps.html#C0fXwFyJeWhPKz7A.99