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