~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to tests/qmltests/README

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
For qmluitests and unittests tests.
 
2
 
 
3
 
 
4
General guidelines
 
5
==================
 
6
 
 
7
Tests under qmluitests target should be designed in a way that they can be run either
 
8
automatically (with qmltestrunner) or manually (with qmlscene). So make sure you
 
9
add UI controls for manual interaction and labels for monitoring output when needed.
 
10
 
 
11
The order in which tests are run should not matter. The test application
 
12
should be in its initial state before each and every test function is called.
 
13
Therefore it should be reset when a test function finishes or before the next
 
14
one starts. A convenient way of doing so is using the init() function of the
 
15
TestCase component. It gets called automatically before each test function.
 
16
 
 
17
The name property of [Unity]TestCase does not include a 'Test' suffix.
 
18
Both [Unity]TestCase and their functions are placed after properties
 
19
and Components being tested.
 
20
e.g.:
 
21
    Item {
 
22
        Component { }
 
23
 
 
24
        Component { }
 
25
 
 
26
        TestCase {
 
27
            name: "Launcher"
 
28
 
 
29
            property var exampleProperty
 
30
 
 
31
            function test_something() {}
 
32
        }
 
33
    }
 
34
 
 
35
 
 
36
Documenting
 
37
===========
 
38
 
 
39
When you write a test function, try to explain what it's trying to check, what's
 
40
the use case. Because in most cases the name of the test function is not expressive
 
41
enough.
 
42
e.g.:
 
43
    // Checks that the filter toggle button, the one that says "View All (xy)",
 
44
    // shows up only when it's possible for the grid to be expanded.
 
45
    function test_filterToggleButton()
 
46
 
 
47
 
 
48
Hints and tips on test API usage
 
49
================================
 
50
 
 
51
The compare() function can take a third, optional, argument. It is the error
 
52
message that will be displayed when the test fails. Thus, if you use it, you
 
53
should talk about the failure case, not about the expected/successful one.
 
54
 
 
55
Wrong:
 
56
    compare(newAppScreenshot.withBackground, false,
 
57
            "switched app have background disabled")
 
58
Right:
 
59
    compare(newAppScreenshot.withBackground, false,
 
60
            "switched app have background enabled")
 
61
Best:
 
62
    compare(newAppScreenshot.withBackground, false,
 
63
            "screenshot of app being brought to foreground has unnecesary background")