How do I run a single unittest inside a sikuli script?

Asked by Robin Siebler

I have several suites of unit tests inside my sikuli script. How would I run a particular test from a specific suite from the command-line?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

You have to provide the test case name and the test name as user args on the command line and then in your script have something like that:

The selection of the tests:
suite = unittest.defaultTestLoader.loadTestsFromName(name) or
suite = unittest.defaultTestLoader.loadTestsFromNames((name1, name2, name3))

where names are dotted names like
MyTestCase.testXYZ

to customise this use eval like this:

suite = eval("unittest.defaultTestLoader.loadTestsFromName(%s.%s) "%(myclass, mytest))

where my class, mutest are evaluated from the user args.

Revision history for this message
Robin Siebler (robinsiebler-dslextreme) said :
#2

Thanks RaiMan, that solved my question.