Scripted GUI Testing & launching engine from command line?
Peter W A Wood
peterwawood at gmail.com
Tue Feb 24 04:19:20 EST 2015
I always thought that LiveCode would make it easy to write scripted tests of GUI applications as it is based on messages. In fact, I’m a little surprised that there doesn’t seem to be much use of scripted testing either by RunRev or the community. I started to experiment with a very simple test, it worked a treat.
I made a simple stack called GUI.livecode with Field1, Field2 and Button. The Button script copies the content of Field1 to Field 2.
I then made another stack, TestGUI.livecode, with a single Field “Report” and the following openStack handler:
local tFailed = 0
local tPassed = 0
show stack "GUI"
put "testing" into Field "Field1" of card "Main" of stack "GUI"
send mouseUp to Button "Button" of card "Main" of stack "GUI"
if "testing" = text of Field "Field2" of card "Main" of stack "GUI" then
Add 1 to tPassed
Add 1 to tFailed
put "Number of Tests:" && tPassed + tFailed & return into Field "Report"
put "Tests Passed: " && tPassed & return after Field "Report"
put "Tested Failed: " && tFailed & return after Field "Report"
This worked as I expected giving me confidence that I am correct in believing that it is easy to write scripted GUI tests with LiveCode. Whilst it is good to be able to run such tests in the IDE, I personally would also like to run them from the command line. I did try using LiveCodeServer to launch the test using GO but, as I’m sure you all know, you can’t run GUI stacks from LiveCode Server.
I guess that I can build a standalone of the Test stack that I can launch from the command line but was hoping there is an easier way. Is there any way to launch the GUI engine from the command line and automatically run a stack?
More information about the Use-livecode