<div dir="ltr">Recently, for the the task "Automated Activity Testing" in GCI, I made a basic Activity Test example and implemented a way to run them.<div><br></div><div>I wrote a basic UI test and a basic unit test for for Calculate, which can be seen in this merge request - <a href="http://git.sugarlabs.org/calculate/mainline/merge_requests/13">git.sugarlabs.org/calculate/mainline/merge_requests/13</a> </div>
<div><br></div><div>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. <br>
Similarly the integration test folder contains UI tests starting with "test_". <br>Python's inbuilt unittest module is used for unit tests and a extended version of unittest is used for UI tests.</div><div><br>
</div><div>These tests can be executed using ./setup.py check<br>setup.py also takes a optional argument of which set of tests to run - </div><div>./setup.py check integration</div><div>./setup.py check unit</div><div><br>
</div><div>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. <br>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.</div>
<div><br></div><div>I think this is all you need to get started writing tests for your activity.</div><div>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.</div>
<div><br></div><div>Thanks,<br>Sai Vineet.</div><div><br></div><div><br></div></div>