[Sugar-devel] Automated Activity Tests

Sai Vineet saivineet89 at gmail.com
Tue Jan 7 10:02:31 EST 2014


Recently, for the the task "Automated Activity Testing" in GCI, I made a
basic Activity Test example and implemented a way to run them.

I wrote a basic UI test and a basic unit test for for Calculate, which can
be seen in this merge request -
git.sugarlabs.org/calculate/mainline/merge_requests/13

To write tests, a "tests" folder must be made inside the bundle path of
your activity. Inside that directory, there can be a "unit" and a
"integration" subfolders. The unit test folder is supposed to contain
tests. The test files begin with "test_", so that modules you have made for
convenience testing do not get executed uselessly.
Similarly the integration test folder contains UI tests starting with
"test_".
Python's inbuilt unittest module is used for unit tests and a extended
version of unittest is used for UI tests.

These tests can be executed using ./setup.py check
setup.py also takes a optional argument of which set of tests to run -
./setup.py check integration
./setup.py check unit

The UI test is a bit hard to follow, so I ask you to look at the test
examples in the Calculate commit I made above.
The sugar3.test.unittest module's UITestCase class is used for UI tests.
This class has a context manager called run_activity, which starts the
activity. There should be a bundle_id property set for the test case, which
tells run_activity what bundle_id should be passed to sugar-launch for
launching the activity.

I think this is all you need to get started writing tests for your activity.
And I would like to use this opportunity to thank Walter Bender. Thank you
for mentoring us impatient sutdents. I know it was hard for you.

Thanks,
Sai Vineet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140107/817694d7/attachment.html>


More information about the Sugar-devel mailing list