QA SoftVision Team/Mobile/Writing tests

< QA SoftVision Team‎ | Mobile
Revision as of 08:44, 10 September 2012 by AdrianT (talk | contribs)

Getting Started

  • You can find information about setting up the enviroment for running the tests here
  • Please make sure to look over this page for some general information about Robocop tests.
  • Robocop is a Java API based on the Robotium API used for automation testing on the Android OS
  • The existing test cases can be found in the sorce directory under the folder mobile/android/base/tests
  • The class that will cover the text will have to be named the same as the test file
  • The test file name should be test[Feature_to_be_tested].java.in
  • The test must be included in the same package as all other Robocop tests

Basic structure of the test

package org.mozilla.fennec_root.tests; // Robotium test package

import org.mozilla.fennec_root.*; // import the package in order to be able to reuse classes if needed

/*
Insert info about the test here - a basic description of what the test does
 */
public class test[Feature_to_be_tested] extends BaseTest {
    @Override
    // This method is needed in the BaseTest class
    protected int getTestType() {
        return TEST_MOCHITEST; // Test type should remain Mochitest
    }
    /* 
    * This is the class constructor 
    * This method will contatin the test that will be ran
    */
    public void testLoad() {
   
    }
}
  • This is a basic structure of a Robocop test
  • Each test class must have three methods:
    • protected void setUp() // Starts Fennec and sets up commonly used member variables. This is usually very similar for every test class
    • public void test[YourFeature]() // Your test code goes here. Use the Robocop API to access Fennec elements, click, send keys, and assert conditions.
    • public void tearDown() // Clean up.
  • If your tests extends BaseTest then you will not need to add the methods setUp() and tearDown() as they are already defined in BaseTest
  • If you need to do extra clean-up, like removing entries you added in a database for e.g., the tearDown() method can be overwrittern but make sure the first line of the method is super.tearDown(). The same is applicable for setUp().