QA/Mozmill Test Automation/Test Modules Refactor

Overview

Lead: Anthony Hughes
Co-workers: TBD
Dates: TBD
Status: In process of determining style guidelines
Repository Location: TBD
Tracking Bug(s) bug 604700
Documentation:

Project Details

Summary

The purpose of this project is to ensure all tests are implemented using an agreed style guideline. The workflow of this project will mostly be parallel with the Shared Modules Refactor project. This project will be rolled out in multiple phases.

Style Guidelines

The Mozmill Style Guide v1.0 has been created. The following refactoring work is an effort to implement those guidelines throughout the mozmill-tests repository. This refactoring will be implemented in multiple phases, outlined below.

Refactoring

Phase I

Goal Implement lowest hanging fruit, make all tests reflect the styleguide
bug Replace all constants with CONSTANTS
  • gDelay, 100 => DELAY
  • gTimeout, 5000 => TIMEOUT
  • sleep() parameter => SLEEP_TIMEOUT
  • unique timeouts => CONSTANT (ie. SEARCH_TIMEOUT)
bug Replace discrete, unchanging values with CONSTANTS
bug Migrate tests away from testGeneral
bug All test pages in LOCAL_TEST_PAGES array
bug Replace waitForEval() with waitFor() where possible
bug Replace DELAY/TIMEOUT with waitFor() where possible
bug License block formatting
  • "the Mozilla Foundation"
  • contributor list alignment
bug All error messages use format:
  • message + " - got " + condition1 + ", expected " + condition2
  • message uses positive wording
bug Whitespace formatting
  • No trailing whitespace
  • 1 newline at end of file
  • 2-space indentation where appropriate
  • Wrap on 80-characters where appropriate
bug Replace sleep() with waitFor() where possible
bug Extract any new elementslib... from function parameter list
bug Replace all array iteration with Array.forEach()
bug Replace anonymous functions with named functions
bug Adopt consistent commenting style
bug All iterators as i, not ii
bug Adopt consistent conditional cuddling

Note: The above comes from the agreed to refactoring guidelines

Phase II

Goal: Bring tests in-line with Shared Module Refactor

Outstanding Items

Discussion here

Arrays
  • Block style
    • What style?
    • Single Index
    • Multiple Index
    • Multiple Index, Multiple Object
Sleep()
  • When is sleep() ok? Is it ever ok?
Local Test Pages
const LOCAL_TEST_PAGES = [
  { url: 'some url', id: 'some id' },
  { url: 'some url', id: 'some id' }
];
  • Should always be declared as a constant Array
  • Use array block formatting
  • Name "LOCAL_TEST_PAGES"
Test Files API Module
  • We should have a module specific to loading of test files
Parameter in setupModule() & teardownModule()
  • Is module needed, wanted?
Error Messages
"Expected <element> to be <state>"

"Expected password-save notification bar to be visible"
  • Messages should be positive in nature
  • <element> should be what the element represents
  • <state> should be what state we expect that element to be in
Parameter Naming
  • param or aParam?
  • Example: label or aLabel
  • the latter is common in Mozilla coding styles
Scope of Constants
  • Global or within the tightest scope?
Review Guidelines

What are our "golden-rule" guidelines for different review states?

  • r?
  • r+
  • r-
  • feedback?
  • feedback+
  • feedback-