Friday, February 28, 2014

Android Application Testing can be performed with two basic functionality of testing i.e Manual and Automation Testing.

Well, Android Application for manual testing there is always the Android Virtual Device (AVD) tool. It should be easily accessible from IDE. Otherwise, we have to buy an Android-enabled device and fingers should be used. Android Application testing is done with different aspects as there is type with native and web application testing. First the android application should be install in the device or Android virtual Devices.We go through the functionality, usability and consistency for any android application that we build up. The aim of our testing is to make application bug free so we should understand the bug detection saves a huge amount of resources and reduces the maintenance costs. This is the best known reason to write the software test for android application development project. As the witting the test gives deeper understating of requirement and the problem to be solved. The major part we have to be considering while manual testing in android application are:
Functional Testing:  We will go through the functional testing for android application to ensures that the application is working as per the requirements. Most of the test conducted for this is driven by the user interface and call flows. Functional Test will focus on validating that tasks/defects (as mentioned in Test Scope) have been implemented/fixed as expected. Test Scope define with the objective of test plan describes specifically what you want your testing to accomplish.
Regression Testing: Regression Test will be performed to ensure that the specific changes (enhancements/fixes as mentioned in Test Scope) have not adversely affected any other functionality. The purpose of regression testing in android application is to provide a general assurance that no additional errors were introduced in the process of fixing other problems. Regression testing is commonly used to test the system efficiently by systematically selecting the appropriate minimum suite of these needed to adequately cover the affected change. Common methods of regression testing include re executing previously run tests and checking whether previously fixed defects have re-emerged. The main reasons for regression testing in android application is that it’s often extremely difficult for a android programmer to figure out how a change in one part of the application will affect other parts of the application.

Unit Testing: Unit testing can be performed by the programmers to test the android application. Junit is the term used for the Unit Testing which is the de-facto standard. It performs the test object in isolation and in a repeatable way. It is usually rely on mock objects. The goal of nit testing is to isolate each part of the program and show that the individual parts are correct .A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. Unit tests find problems early in the development cycle.

Version Compatibility Testing: Version compatibility test, comprising of a non-exhaustive set of tests that aim at ensuring that it works in the different Android Version, will be executed as soon as a new build in QA Environment is received. The purpose of this test is to verify whether the build is stable for different Android Versions.

Performance Testing: Performance testing should be done to measure the performance of android application in a repeatable way. When testing the performance if it cannot be measurable then application cannot be improved. We should focus towards the premature optimization which does more harm than good. Android Application can be tested with the different devices or AVD emulator. It depends upon the hardware part of the devices. As to the better system it will provide the best performance and to the least it will be minor.

Security Testing: Security testing in android application is very important that it should follow all the security objectives. They are confidentiality, Integrity, Authentication, Authorization, Availability, etc.

Integration Testing: Integration testing defines how the components work together in android application. We have to ensure that modules have been unit tested for android components which needs integration with the system. Many testing framework facilitates the integration during the android application testing.

The purpose of integration testing is to verify functional, performance, and reliability requirements placed on major design items. These “ design items”, or groups of units , are exercised through their interfaces using black box testing , success and error access being simulated via appropriate parameter and data inputs.

Usability Testing: Usability testing is carried out to verify if the application is achieving its goals and getting a favorable response from users. This is important as the usability of an application is its key to commercial success. This testing is more feasible during the User Acceptance Testing.

Others:

Memory Leakage Testing: This testing is done to find that how much memory is being used by android application in devices. It is dependent to the performance and size of the application. If the size of application is higher it will take more memory in the application. Though we should test the total memory allocation by application in the devices to prevent from memory leakage.


What to Test

Testing Android Application is challenging for the tester one should have good knowledge of software testing process. There are some ideas for testing which should be in the priority before testing android application. These are the external part of testing as we have discussed all the testing process above. Some of the ideas for testing are as follows:

  • Change in orientation
  • Change in configuration
  •  Battery life
  •  Dependence on external source

Key Challenges in Android Application Testing


  • Variety of Mobile Devices - Mobile devices differ in screen sizes, input methods (QWERTY, touch, normal) with different hardware capabilities.
  •  Different Resolution – Android application should be applicable to different resolutions of devices. One can used the android devices for the feasible we can test in avd emulator by making different resolution of emulator. There is diversity in Mobile Platform/OS so testing a single application across multiple devices running on the same platform and every platform poses a unique challenge for testers.
  •  Scripting - While testing the android application there may be the variety of devices which makes executing the test script (Scripting) a key challenge. As devices differ in keystrokes, input methods, menu structure and display properties single script does not function on every device.

Test Automation


Android Application testing integrates with the JUnit framework and based with JVM and for testing which required Android System. Android framework is an important part of the development environment which provides and architecture and powerful tools that help to test every aspect of application at every level from unit to framework. Some of automated testing frameworks or tools for Android Applications are including not limited to Activity Instrumentation, Selenium WebDriver2.0, MonkeyRunner, Robotium, or Roboelectric. Android has basic support for instrumentation tests, one of the possibilities being the Activity Instrumentation Test Case class belonging to the android.test package and extending JUnit’s Test Case in order to provide functional testing of Android activities. When an application is tested, each instrumented activity is launched inside the Virtual Machine on and Android emulator or an actual android device. 


What can we test?
  • Classes
  • User Interface
  • Services
  • Content Providers etc

The major return back of Android frameworks supports followings:

  • Android Test suites are based on JUnit. You can use plain JUnit to test a class that doesn’t call the android API, or Android’s JUnit extensions to test android components.
  • The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.
  • Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.
  • The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDEs. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.
  • The SDK also provides monkey runner, an API for testing devices with Python programs, and UI/application Exercise Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.
The above points describes the fundamentals of the Android testing framework, including the structure of tests, the APIs that you use to develop tests, and the tools that you use to run tests and view results. 

The following diagram summarizes the testing framework: 





Figure 1.0

Test Structure: Android's build and test tools assume that test projects are organized into a standard structure of tests, test case classes, test packages, and test projects. Android testing is based on JUnit. In general, a JUnit test is a method whose statements test a part of the application under test. You organize test methods into classes called test cases (or test suites). Each test is an isolated test of an individual module in the application under test. Each class is a container for related test methods, although it often provides helper methods as well. In JUnit, you build one or more test source files into a class file. Similarly, in Android you use the SDK's build tools to build one or more test source files into class files in an Android test package. In JUnit, you use a test runner to execute test classes. In Android, you use test tools to load the test package and the application under test, and the tools then execute an Android-specific test runner.


Test Project: Tests, like Android applications, are organized into projects. A test project is a directory or Eclipse project in which you create the source code, manifest file, and other files for a test package. The Android SDK contains tools for Eclipse with ADT and for the command line that creates and updates test projects for you. The tools create the directories you use for source code and resources and the manifest file for the test package. The command-line tools also create the Ant build files you need.

The testing API for android testing are as follows:

  •  JUnit
  •   Instrumentation
  •  Test case classes
  •   AndroidTestCase
  •   ApplicationTestCase
  •   InstrumentationTestCase
  •   Assertion classes
  •   Mock object classes
  •   Simple mock object classes
  •    Resolver mock objects



Key Classes for testing framework are as follows:

  •   Instrumentation TestRunner
  •   Android.test
  •   Android.test.mock
  •  Junit.framework

Activity Testing:

Activity testing is partially dependent on the Android instrumentation framework. It consists of components, activities which have a complex life cycle based on cal back methods; these can’t’ be invoked directly except by instrumentation. More often we can test the activity of android application by using instrumentation and other test facilities. Activity will not participate in the normal interactions with the system. And some methods should be avoided and will throw the exceptions if called. We can perform the Automation Testing with the help of Activity testing tools. There are methods, classes and activity packages which we will use to create the simple android application for testing.


UI Test:

The final stage of testing is to verify that UI of application. Your special consideration should be taken if your tests involve UI components. As you may have already known, only the main thread is allowed to alter the UI in Android. Thus a special annotation @UIThreadTest is used to indicate that particular test should be run on that thread and would have the ability to alter the UI. On the other hand, if you only want to run parts of your test on the UI thread, you may use the Activity.runOnUIThread(Runnable r) method providing the corresponding runnable containing testing instructions.


A helper class TouchUtils is also provided to aid in the UI test creation allowing the generation of events to send to the views, such as:

  • Click
  • Drag
  •  Long click
  •  Scroll
  • Tap
  • Touch

Service Testing:

To test a service you use the ServiceTestCase class. It provides the startService() and bindService() methods to interact with the service. The bindService) return immediately a IBinder object without callback. Testing asynchronous processing in services is a challenge as the duration of this processing may vary. It is good practice to test if the service handles correctly multiple calls from startService(). Only the first call of startService() triggers the onCreate() of the service but all calls trigger a call to onStartCommand() of the service.








Saturday, February 22, 2014

Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language. Selenium provides a test domain specific language (DSL) to write tests in a number of popular programming languages including C#, Java, Groovy, Perl, PHP, Python and Ruby. Test playback is possible in most modern web browsers. Selenium deploys on Windows, Linux, and Macintosh platforms.
Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run.
Selenium IDE is not only a recording tool: it is a complete IDE. You can choose to use its recording capability, or you may edit your scripts by hand. With auto complete support and the ability to move commands around quickly, Selenium IDE is the ideal environment for creating Selenium tests no matter what style of tests you prefer.
Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.
Selenium RC comes in two parts. 
1.      A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
2.      Client libraries for your favourite computer language.
The RC server also bundles Selenium Core and automatically loads it into the browser.
Below is a simplified architectural representation...


PHPUnit is a regression testing framework used by the developer who implements unit tests in PHP.

·         Downloading and Installing
 1.)  Selenium IDE
For use with Firefox, download the IDE from the Selenium downloads page (http://seleniumhq.org/download/).  Then install the Selenium-IDE add-on on your Firefox browser. After the installation completes you can run the IDE to create test cases. To run the Selenium-IDE, simply select it from the Firefox Tools menu. It opens with an empty script-editing window and a menu for loading, or creating new test cases.

2.)  Selenium RC

- Make sure that you have Java Runtime installed on your machine.
- Download Selenium RC from downloads page (http://selenium-rc.seleniumhq.org/download.html)
- After extracting the files from the archive, copy the 'selenium-server.jar' file to any location of your choice.
- Start the Selenium RC server from the command-line by issuing the following command:   java -jar selenium-server.jar
This will start the server on port 4444.
- Now the server is ready to accept test commands from your PHP script. Make sure you keep this server running till you finish testing.




3.) PHPUnit
-An easy way to install PHPUnit is to use the PEAR installer. First of all install the latest version of PEAR by supplying following command :
pear install PEAR-1.9.2
 -The PEAR channel (pear.phpunit.de) is used to distribute PHPUnit so make sure that it is registered with your local PEAR environment:
pear channel-discover pear.phpunit.de
-After the channel is registered install PHPUnit:
pear install phpunit/PHPUnit
-Finally upgrade the PHPUnit to its latest version.
pear upgrade phpunit/PHPUnit

·         Running a simple test using Selenium IDE
-Start Selenium IDE in Firefox: Tools->Selenium IDE
-Click on the red record button on the right.
- Browse to http://www.deerwalk.com
- Browse the page and all the links and buttons you clicked will be recorded.
-  Stop the recording by clicking on the record button.
If you click on the ‘Source’ tab of the IDE you can see the test.html generated by selenium.
The ‘table’ tab shows the commands recorded by Selenium.
- Open a new tab in Firefox and click on the Selenium IDE’s play button to run the recorded test.


- The IDE should play your recorded test. The IDE after the test run is shown below. In the ‘Log section’ you can see the various events run by the test. In the table tab you can see that all the rows are green, which means that the test ran successfully.





The interesting part follows – running the same test from PHP. From the file menu, select ‘Export Test Case As…’ and as we are using PHP, select ‘PHP – PHPUnit’. Save the file by the name ‘Example.php’.





This is what we get in Example.php
<?php
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://www.testurl.com/");
  }

  public function testMyTestCase()
  {
    $this->open("/");
    $this->click("link=Services »");
    $this->waitForPageToLoad("30000");
    $this->click("link=Careers »");
    $this->waitForPageToLoad("30000");
    $this->click("link=Blog");
    $this->waitForPageToLoad("30000");
    $this->click("link=Case Studies");
    $this->waitForPageToLoad("30000");
  }
}
?>






·         Actual testing
Now that PHPUnit is installed and the Selenium RC server is up and running, it’s time to run our test we saved before in our ‘Example.php’ file. Type the following on the command-line:
                        phpunit Example
This will start the test. The PHPUnit Selenium driver will execute each test command from your file and send it to the Selenium server, which does the job of launching the appropriate browser, opening web pages, and performing various specified actions; and closing the browser after the test completes.


Now to test the same test case in another browser you simply need to set Browser to the one you want the test to run.

Supported browsers include:

  *firefox
  *mock
  *firefoxproxy
  *pifirefox
  *chrome
  *iexploreproxy
  *iexplore
  *firefox3
  *safariproxy
  *googlechrome
  *konqueror
  *firefox2
  *safari
  *piiexplore
  *firefoxchrome
  *opera
  *iehta
  *custom




·         “Selenese” Selenium Commands
A command is what tells Selenium what to do. Selenium commands come in three 'flavors': Actions, Accessors and Assertions.
Actions are commands that generally manipulate the state of the application. They do things like "click this link" and "select that option". If an Action fails, or has an error, the execution of the current test is stopped.
Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
Accessors examine the state of the application and store the results in variables, e.g. "storeTitle". They are also used to automatically generate Assertions.
Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include "make sure the page title is X" and "verify that this checkbox is checked".
All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc. "waitFor" commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting.

·         Commonly Used Selenese
-open
    opens a page using a URL.
-click/clickAndWait
    performs a click operation, and optionally waits for a new page to load.
-verifyTitle/assertTitle
    verifies an expected page title.
-verifyTextPresent
    verifies expected text is somewhere on the page.
-verifyElementPresent
    verifies an expected UI element, as defined by its HTML tag, is present on the page.
-verifyText
    verifies expected text and it’s corresponding HTML tag are present on the page.
-verifyTable
    verifies a table’s expected contents.
-waitForPageToLoad
    pauses execution until an expected new page loads. Called automatically when clickAndWait is used.
-waitForElementPresent
    pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.



Categories

.
Powered by Blogger.

Popular Posts

Like Us