Application Testing (even when it has modal features)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Application Testing (even when it has modal features)

Sebastián Sastre
Hi all,

  I'm making serveral tests for an application I'm developing. A lot of
them are for the model and some others are testing at application level
(gui, etc) so I have this question:

  How do you do to make the automation of testing, when a test, in
execution, tests code that is calling a (modal) MessageBox?

  Until now, I'm manually answering 'yes' to the MessageBox of that
test but if I need to make 100 tests like that I should buy a bionic
finger :P

  Any help are welcome,

  thank you,

Sebastián


Reply | Threaded
Open this post in threaded view
|

Re: Application Testing (even when it has modal features)

Andy Bower-3
Sebastián,

>   I'm making serveral tests for an application I'm developing. A lot
> of them are for the model and some others are testing at application
> level (gui, etc) so I have this question:
>
>   How do you do to make the automation of testing, when a test, in
> execution, tests code that is calling a (modal) MessageBox?
>
>   Until now, I'm manually answering 'yes' to the MessageBox of that
> test but if I need to make 100 tests like that I should buy a bionic
> finger :P

There are a couple of cases where we have needed to do this when
testing the Dolphin browsers. In these cases we chose the bionic finger
approach -- what we do is to script the MessageBox using an API called
AutoIt.

http://www.hiddensoft.com/AutoIt/

There is an ActiveX version of this, called AutoItX, and you can use
Dolphin's ActiveX Component Wizard to generate the interfaces for it.
I can't remember why now but we found the AutoIt version 2 to be
preferable to the version 3. Below is the test we use for the
ClassBrowserShell to check that changing between class and instance
modes brings up a "do you wish to retain changes" message box:

---
testClassInstanceModes
        | modePresenter methodBrowserPresenter instanceButton classButton
method |
        modePresenter := browser instVarNamed: 'modePresenter'.
        methodBrowserPresenter := browser instVarNamed:
'methodBrowserPresenter'.
        instanceButton := modePresenter view viewNamed: 'instanceMode'.
        classButton := modePresenter view viewNamed: 'classMode'.
        browser actualClass: Object.
        self assert: browser actualClass == Object.
        modePresenter value: #classMode.
        self assert: classButton value.
        self assert: instanceButton value not.
        self assert: browser actualClass == Object class.
        modePresenter value: #instanceMode.
        self assert: instanceButton value.
        self assert: classButton value not.
        self assert: browser actualClass == Object.

        "Test refusal to change mode when a method is changed"
       
        [Processor sleep: 500.
        ApplicationController new sendKeys: 'Y'] fork.
        modePresenter value: #instanceMode.
        method := DolphinTest
                                compile: 'blah3'
                                categories: #()
                                package: packageA.
        browser method: method.
        methodBrowserPresenter sourcePresenter source: 'blah3 ^self'.
        modePresenter value: #classMode
---

Note that we have wrapped the AutoIt control in a class called
ApplicationController and that we fork of a new process just before we
expect the MessageBox to pop-up.  Actually, there is a better way of
doing this than just waiting 500ms-- you could actually wait for a
message box with a particular window title to appear.

I hope this helps.

Best regards,

--
Andy Bower
Dolphin Support
www.object-arts.com


Reply | Threaded
Open this post in threaded view
|

Re: Application Testing (even when it has modal features)

Sebastián Sastre
Andy,

  what a powerfull finger !

  I've made a wrapper too and set it up in the testResource of the
application as #controller so I can sent to it push button commands a
bit delayed or not.

  It's really a simple and clean way to do it.

  thank you,

Sebastián


Reply | Threaded
Open this post in threaded view
|

Re: Application Testing (even when it has modal features)

Sebastián Sastre
In reply to this post by Andy Bower-3
Andy,

  what a powerfull finger !

  I've made a wrapper too and set it up in the testResource of the
application as #controller so I can sent to it push button commands a
bit delayed or not.

  It's really a simple and clean way to do it.

  thank you,

Sebastián