Stefan Lieser | 5 Jan 2006 14:59
Picon
Favicon

[TFUI] Testing WinForms

Hi,

I program in C# with VS2005 and use NUnit heavily to test my business 
objects.
I tried to use NUnitForms to test the WinForms code but I'm not very happy 
with NUnitForms because to me it is not enough "low-level". For example if 
you want to test what happens if one enters a specific text into a TextBox 
control, NUnitForms sets the Text property of the control instead of 
"typing" the characters as the user would do it. Therefore not all necessary 
TextBox events are fired.

I would like to use a tool that simulates keyboard and mouse activity so 
that even custom control behaviour can be tested. Do you know of such a 
tool?

Sincerely,
Stefan Lieser 

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe@...

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/

<*> To unsubscribe from this group, send an email to:
    TestFirstUserInterfaces-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
(Continue reading)

Adrian Rutter | 5 Jan 2006 16:45
Favicon

Re: [TFUI] Testing WinForms

Hi,

> NUnitForms sets the Text property of the control instead of
>"typing" the characters as the user would do it.

Could you not use the SendKeys class from the .NET Framework Class Library?

Aidy

---------------------------------------------------------------------------------------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from
disclosure. 
If you are not the intended recipient, please telephone or email the sender and delete this message and any
attachment from your system.  
If you are not the intended recipient you must not copy this message or attachment or disclose the contents
to any other person.
---------------------------------------------------------------------------------------------------------------

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe@...

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/

<*> To unsubscribe from this group, send an email to:
    TestFirstUserInterfaces-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
(Continue reading)

Cory Foy | 5 Jan 2006 16:56

Re: [TFUI] Testing WinForms

Adrian Rutter wrote:
> Could you not use the SendKeys class from the .NET Framework Class Library?

I've used SendInput using interop to do screen grabs and had posted it 
if the helps the OP:

http://www.cornetdesign.com/2005/04/screen-print-capture-in-c-using_08.html

I haven't used it to simulate user keystrokes. We use TestRunner or 
WinRunner for that kind of testing.

Cory

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe@...

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/

<*> To unsubscribe from this group, send an email to:
    TestFirstUserInterfaces-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Tim Haughton | 5 Jan 2006 16:45
Picon
Gravatar

Re: [TFUI] Testing WinForms

On 05/01/06, Stefan Lieser <slieser@...> wrote:
>
> Hi,
>
> I program in C# with VS2005 and use NUnit heavily to test my business
> objects.
> I tried to use NUnitForms to test the WinForms code but I'm not very happy
>
> with NUnitForms because to me it is not enough "low-level". For example if
>
> you want to test what happens if one enters a specific text into a TextBox
>
> control, NUnitForms sets the Text property of the control instead of
> "typing" the characters as the user would do it. Therefore not all
> necessary
> TextBox events are fired.
>
> I would like to use a tool that simulates keyboard and mouse activity so
> that even custom control behaviour can be tested. Do you know of such a
> tool?
>

There are tools made by Rational and the like that record and playback
actions on your GUI and check what is happening. These are really in the
realm of regression testing rather than TDD, and I have to say I've never
really found a use for them.

What exactly is it you're trying to test? What aspect of the behaviour? It
may be that you can achieve the desired testing by other methods.

(Continue reading)

Stefan Lieser | 5 Jan 2006 19:48
Picon
Favicon

Re: [TFUI] Testing WinForms

From: "Tim Haughton" <timhaughton@...>

> What exactly is it you're trying to test? What aspect of the behaviour? It
> may be that you can achieve the desired testing by other methods.

Some examples:
- Verify that text entered in a TextBox is propagated to underlying 
controller.
- Verify that controls in a form are enabled/disabled depending on the input 
to other controls.
- Verify that input to a custom TextBox control is of specified format.
- Verify that a DataGridView contains the correct data and that entering 
text into cells results in the correct updates to the business domain.

I did most of these things by hand in the last years. But the more you learn 
about automated testing and the more you see your code quality being better 
and better because of TDD, the more you want to automate the GUI tests.

So I will try the SendKeys class...

Sincerely,
Stefan Lieser 

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe@...

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/
(Continue reading)

Dan Bunea | 5 Jan 2006 22:01
Picon

Re: [TFUI] Testing WinForms


Hi,

In my opinion testing if the text reaches the controller, after being  
entered into a textbox, is not very helpful, and it doesn't seem like a  
very useful test to me.

Now testing from the customer's perspective, you should test only from the  
user interface, and have nothing to do with the controller. A test should  
follow the steps of preparing, acting and verifying but all from one  
perspective, and if that's the user perspective then , maybe entering a  
username and a password in a login panel is the preparation and acting is  
clicking the login button, and depending on the data introduced verifying  
is testing whether you've reached the right screen or that you have a  
message box saying that your credentials are wrong. I think that this can  
be very well done using NUnitForms, although I  saw that usually using  
NUnitForms means writing a lot of code (I even wrote something about it:  
http://danbunea.blogspot.com/2005/08/simplifiing-nunitforms-functional.html).

And if you don't want to be testing exclusivly from a customer  
perspective, I think Model View Presenter is a very good choice for TDD  
(http://danbunea.blogspot.com/2005/11/model-view-presenter-is-testing_27.html)

Thanks,
Dan

On Thu, 05 Jan 2006 20:48:23 +0200, Stefan Lieser <slieser@...>  
wrote:

> From: "Tim Haughton" <timhaughton@...>
(Continue reading)

Stefan Lieser | 6 Jan 2006 09:39
Picon
Favicon

Re: [TFUI] Testing WinForms

Hi Dan,

> In my opinion testing if the text reaches the controller, after being
> entered into a textbox, is not very helpful, and it doesn't seem like a
> very useful test to me.

How do you make sure that the data entered into a form is propagated to your 
business domain?

> Now testing from the customer's perspective, you should test only from the
> user interface, and have nothing to do with the controller. A test should
> follow the steps of preparing, acting and verifying but all from one
> perspective, and if that's the user perspective then , maybe entering a
> username and a password in a login panel is the preparation and acting is
> clicking the login button, and depending on the data introduced verifying
> is testing whether you've reached the right screen or that you have a
> message box saying that your credentials are wrong. I think that this can
> be very well done using NUnitForms, although I  saw that usually using
> NUnitForms means writing a lot of code (I even wrote something about it:
> http://danbunea.blogspot.com/2005/08/simplifiing-nunitforms-functional.html).

If for example the user wants to be able to commit your login dialog by 
clicking the Ok button or by pressing the Return key. How do you make sure 
your dialog supports both?

I think NUnitForms is a good tool for doing UI tests. The problem I have 
with it is, that the low level keyboard and mouse actions do not work in all 
scenarios. Using .NET's SendKeys class solves some of those problems. I will 
investigate if it makes sense to use SendKeys inside of NUnitForms.

(Continue reading)

Dan Bunea | 6 Jan 2006 09:58
Picon

Re: [TFUI] Testing WinForms

Hi again,

On Fri, 6 Jan 2006 09:39:05 +0100, Stefan Lieser <slieser@...>  
wrote:

> Hi Dan,
>
>> In my opinion testing if the text reaches the controller, after being
>> entered into a textbox, is not very helpful, and it doesn't seem like a
>> very useful test to me.
>
> How do you make sure that the data entered into a form is propagated to  
> your
> business domain?

If I test like a user I need to see if the data is propagated into the  
layers below as a user could. Entering some text into a field, should  
probably have some inpact in another screen and I could checkk there if  
that happened.
>
>> Now testing from the customer's perspective, you should test only from  
>> the
>> user interface, and have nothing to do with the controller. A test  
>> should
>> follow the steps of preparing, acting and verifying but all from one
>> perspective, and if that's the user perspective then , maybe entering a
>> username and a password in a login panel is the preparation and acting  
>> is
>> clicking the login button, and depending on the data introduced  
>> verifying
(Continue reading)

Gishu Pillai | 6 Jan 2006 07:35
Picon
Gravatar

Re: [TFUI] Testing WinForms

> And if you don't want to be testing exclusivly from a customer
> perspective, I think Model View Presenter is a very good choice for TDD

Ditto. Coupling MVP with Dynamic Mocks is the fastest that I have been
able to move.
Sometimes you'll have x amount of untested code in the View (Funky
controls with jazzy events). But on the whole quite safe... NCover
says 83%..

So disabling buttons would be IView.DisableButton( args ). You would
be able to test that Presenter calls this method during a test
scenario.
Such a simple case as Disabling buttons can also be tested by testing
the Button's enabled property in the ViewImplementation test fixture
TestDisableButton_ButtonsAreGrayedOut()
But let's says I have a BF Control and I want to test that dropping
the combo box in cell [4,2] and selecting Item No 3 and pressing enter
should do this... then that my friend is going down a harrowing dark
alley.

HTH
--- Gishu

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe@...

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/
(Continue reading)

Stefan Lieser | 6 Jan 2006 16:16
Picon
Favicon

Re: [TFUI] Testing WinForms

Hello Dan,

>> How do you make sure that the data entered into a form is propagated to
>> your business domain?
>
>
> If I test like a user I need to see if the data is propagated into the
> layers below as a user could. Entering some text into a field, should
> probably have some inpact in another screen and I could checkk there if
> that happened.

Fully agreed. You make an end to end test. But often it is necessary to test 
at a finer granularity. Anyway. My main problem was testing the UI by 
simulating keyboard and mouse.

> I think NUnitForms already supports this trough KeysController
> (http://cvs.sourceforge.net/viewcvs.py/nunitforms/NUnitForms/source/NUnitForms/KeyboardController.cs?rev=1.8&view=auto)
> but I have never investigated.

It does not work in all circumstances. Furthermore if you use NUnitForms for 
example on a TextBox and write

myBoxTester.Enter("bla");

I would expect that NUnitForms "types" the text into the TextBox control so 
that all events are fired. Instead NUnitForms sets the TextBox.Text 
property.

> In my belief it is much simpler to verify
> the two scenario's by hand then writing a test.
(Continue reading)


Gmane