Testing Tips

From Documentation
Revision as of 04:16, 29 November 2010 by Tomyeh (talk | contribs)

ID and UUID

By default, the desktop's ID and component's UUID are randomized, such that the chance to pick up a wrong component is minimized if the sever is restarted. Since component's UUID will become DOM element's ID at the browser, it means the DOM element's IDs will change from one test run to another.

There are generally two solutions for it.

  1. Not to depend on DOM element's ID. Rather, use component's ID and/or component's parent-child-sibling relationship.
  2. Implement IdGenerator to generate UUID in a predictable and repeatable way

Approach 1: Use Widget's ID

, i.e., use jq (client-side API) instead

    • jq allows your test code to access the components directly, so the test code could depend on component's ID (Component.getId()) and the component tree (Component.getNextSibling(), Component.getFirstChild() and so on).
    • This is the suggested approach since it is much easier to test in the component level (aka., the widget level, Widget).
    • For example, ZTL takes this approach to make the test code independent of DOM structures.
    • With this approach, you still can verify the DOM structure if you want, since it can be retrieved from widget's Widget.$n().

Approach 2: Implement ID Generate

Version History

Last Update : 2010/11/29


Version Date Content
     



Last Update : 2010/11/29

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.