Cannot run Unit Tests from windows command line

Asked by Ben Turner

After concluding that Unit Testing via the Sikuli GUI doesn't work in 0.10.2, I've tried running from the command line using the updated batch file.

I was using a simple Windows Calc test, taken from http://stackoverflow.com/questions/2854141/help-sikuli-unit-test-can-not-run - obviously I have adjusted the Calc test to use actual screengrabs I've taken.

If I remove the "def test_calculator(self):" line and unindent that method, I can run it straight from the IDE (as it happens, it fails on the assert, but this is still running so no worries). I can also then run it from the command line as follows :

c:/tmp> Sikuli-IDE.bat -r Calc.sikuli

And this runs, again popping up a Java dialog to tell me about the failed assert. But trying to run it as a Unit Test (having replaced the test method line back in) I am getting no joy. What I see is :

c:/tmp> Sikuli-IDE.bat -t Calc.sikuli
null

That's it. It just returns null. I've tried changing test methods, removing asserts, ensuring JUnit and Sikuli binaries are on my path or classpath, but I can't get it to do anything other than return null.

Maybe the fact that I can't get any Sikuli Unit Testing working via the IDE means I should focus more on that, although I can see a bug for that (https://bugs.launchpad.net/sikuli/+bug/581712). So overall I am pretty stumped on how to get Sikuli up and running as a Unit Test within my windows environment.

Anything else I might try ? Or is it best to rollback to 0.9.9 (which I've not tried yet) and wait for a known, reported bug to be added into a new release ?

Thanks,
Ben

Question information

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

Just tried on my Win7 with this little example (it is 10.2):

def setUp(self):
   print "in setUp"

def tearDown(self):
   print "in tearDown"

def test1(self):
   print "in test1"

saved this to utest.sikuli, went to test pane and ran it from there and I got the expected results.

I do not rely on path and either go to the dir with the script and say "c:\Program Files\Sikuli\Sikuli\Sikuli-IDE.bat" or go to the Sikuli program folder and qualify the script with its full path.

Revision history for this message
Ben Turner (ben-turner) said :
#2

Thanks for the reply - problem solved !

Overall answer, when Unit Testing seems to do nothing, press Alt+Shift+C and check the Message box. For my Calc example, it was erroring on the following command

with(Region(find("calculator.png"))):

This throws a message about wait being a reserved word in Python 2.6 - not sure what the correct way to specify "do the following commands within a region is". For one command, the answer was http://sikuli.org/documentation.shtml#/trac/wiki/How%20to%20find%20within%20a%20region? anyway.

So why had I decided Unit Testing was broken ? Well, every OTHER test I'd written was named with spaces. This causes problems with trying to execute the test, as I think it uses the filename as the class name in Python, and spaces are not valid for that. I took the spaces out of my test filenames, and they also work now as well.

In short, the only feature I can see being desireable here is that when the Unit Test simply fails to load, it would be good to detect this and shutdown the test, re-enabling the run button for when it's been made at least runnable (even if it then doesn't pass). Until then, a reboot of the IDE is required, which can be quite painful when your discovering the language still and making errors like I have been.

But very happy Unit testing DOES work though. Thanks for the assistance,
Ben