Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Test driving QML


Published on

How to test-drive your Qt QML code. Overview on how you do simple testing, UI level testing, synchronous testing, data-driven testing.

These are the slides used on the Tampere MeeGo meetup on March 15, 2011 and text may not be super clear for those who didn't attend the meetup. You can still download the example and examine it.

Published in: Self Improvement
  • Be the first to comment

Test driving QML

  1. 1. Test-Driving QML<br />Artem Marchenko<br />March 15, 2011<br />
  2. 2. Artem Marchenko<br />Product Manager, Researcher, Coach<br />Product Manager shipping multi-hundred MEur products<br />Scrum Master, Practitioner, Product Owner and Coach<br />Three times Forum Nokia Champion<br />Private entrepreneur<br />Available for hire<br /><br />
  3. 3. Test-Driven Development. Or just testing QML<br />What TDD is about<br />Getting started<br />Simple Synchronous test<br />Simulating mouse and keyboard actions<br />Asynchronous tests (verifying callbacks)<br />Data-driven tests<br />Current limitations<br />Q&As<br />
  4. 4. Test-Driven Development<br />Remove duplication<br />
  5. 5. Example of a QML-code developed via TDD<br />
  6. 6. Getting started 1(3)<br />git clone git://<br />Cloning into qtest-qml...<br />remote: Counting objects: 888, done.<br />remote: Compressing objects: 100% (669/669), done.<br />remote: Total 888 (delta 445), reused 393 (delta 187)<br />Receiving objects: 100% (888/888), 411.11 KiB, done.<br />Resolving deltas: 100% (445/445), done.<br />cd qtest-qml/<br /><br />make<br />make install<br />make docs<br />make check<br />Project page:<br />
  7. 7. Getting started 2(3)<br />Create the simplest test in your project<br />
  8. 8. Getting started 3(2)<br />And a script that runs the test: in this case<br />#!/bin/bash<br />clear<br />/Users/artem/QtSDK/Desktop/Qt/471/gcc/bin/ tst_tddCalculator2.qml <br />
  9. 9. Simple synchronous tests<br />
  10. 10. UI level: simulating mouse click<br />
  11. 11. UI level: simulating touch and drag<br />
  12. 12. Asynchronous testing: tryCompare<br />
  13. 13. Asynchronous testing: SignalSpy<br />
  14. 14. Data-driven tests<br />
  15. 15. Current Limitations<br />Installation doesn’t install qtest-qml to QtCreator 2.1 Tech Preview<br />Not that you would need it for TDD, but if you are into “just testing” already written code, debugger may be helpful<br />Bug: only one TestCase is allowed:<br />It makes init() and cleanup nearly useless<br />Organize your test structure by your own tools<br />Small difficulties comparing built-in classes (e.g. color)<br />toString() helps most of the time<br />
  16. 16. Current limitations<br />Very strange errors when object/property can be accessed e.g. because of a typo<br />Segmentation faults, sometimes even “file not found”<br />In 95% of cases that is a typo or an attempt to access a non-public property<br />
  17. 17. Current limitations<br />SignalSpy can only count <br />It cannot examine the signal arguments or the state of other objects<br />Benchmarking is a part of a qtest-qml, but doesn’t work properly<br />That is I failed to make it run for a given amount of times (most of the time it does just a single run)<br />No built-in device test runners<br />Though you can certainly, embed a “run tests” button right into your application<br />
  18. 18. Thank you<br />Q&As time<br />You can find these slides at<br />