# Ruby access to Win Forms application

**URL:** <https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010>\
**Category:** Ruby\
**Created:** [August 26, 2007, 2:15am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010 "2007-08-26T02:15:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 2:15am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/1 "2007-08-26T02:15:40Z")

</div>

I am a QA Engineer implementing a Ruby-based test framework to test  
the applications in my organization…the issue I have is about 20% of  
what we do is Windows Forms (.NET) applications…can I use Win32OLE  
for this, or would I need to use something like Ruby .NET or  
IronRuby? Basically the idea of the application under test is that it  
makes a socket connection to a server, then the server passes messages  
to it. When a message is passed of a particular type, a “screen pop”  
is generated. So what I want to do in a Ruby test is to:

1. Set up a mock of the server and establish connection with the  
application.
2. Send the application a message which should result in a screen  
pop.
3. Verify the screen pop came up.

Anyway…any advice on this is greatly appreciated. I’ve done some  
Ruby work but am a newbie as it pertains to using it to access  
Windows.

Jim

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 3:32am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/2 "2007-08-26T03:32:45Z")

</div>

Just using the win32 apis with things like FindWindow to check the popup  
window is showing?

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 5:20am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/3 "2007-08-26T05:20:53Z")

</div>

Jim K. wrote:

> I am a QA Engineer implementing a Ruby-based test framework to test  
> the applications in my organization…the issue I have is about 20% of
> 
> > what we do is Windows Forms (.NET) applications…

The majority of your tests simply must use .NET. They should run as  
close as  
possible to the tested code. Every step farther from that code, the  
fuzzier  
and sloppier the tests get.

In general, there’s always a role for tests that are easy to script. Raw  
Ruby, or Ruby+YAML, would allow you to invent graceful DSLs that  
simultaneously document and test business rules. Yet that’s not where  
you  
should start.

> 1. Set up a mock of the server and establish connection with the  
> application.
> 2. Send the application a message which should result in a screen  
> pop.
> 3. Verify the screen pop came up.

Mock the thing that pops the screen up. You don’t need to test the GUI  
itself, because you aren’t going to refactor or upgrade that.  
(Hopefully!)  
You need tests that cover only your own logic. That logic isn’t going  
anywhere if a test simply catches its outputs _before_ those outputs go  
into  
the real GUI.

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 7:50am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/4 "2007-08-26T07:50:59Z")

</div>

> assert\_xpath, assert\_javascript, & assert\_ajax  
> Philip…Thanks for your thoughts…I guess my thought is that since I  
> am the QA guy, and am not writing the program code (I’d say we do  
> “moderately rapid but not agile” development), my job is just to  
> verify that the program works from a user perspective, not to unit-  
> test the code. So far, I’ve been using Ruby/Watir to drive the  
> browser and test our admin utility (which is a web application)…and  
> that’s worked great. The only thing remaining is to be able to  
> “drive” the win32 client so I can verify it responds appropriately to  
> messages it gets from the server. I guess my thought is, if I mock up  
> the client, how do I know the client is working (if I’m not actually  
> running it)?

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 7:45am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/5 "2007-08-26T07:45:58Z")

</div>

On Aug 25, 6:32 pm, Jeremy W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Just using the win32 apis with things like FindWindow to check the popup  
> window is showing?

That’s exactly what I’m trying to do…nothing fancy, and I don’t need  
code-level/unit tests…since I’m the QA guy and not the developer, I  
just want to test the app itself to make sure at the user level, it  
works the way it should. So I’d think something like a FindWindow  
would work perfect…is that accessible through win32ole? Or  
something else?

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [August 26, 2007, 11:29am UTC](https://www.ruby-forum.com/t/ruby-access-to-win-forms-application/113010/6 "2007-08-26T11:29:39Z")

</div>

If your main app is in .NET you may want to try our Ruby Connector. This  
is currently in beta and will be more generally availabale soon ( watch  
the Blog for news! [http://www.sapphiresteel.com/-Blog-](http://www.sapphiresteel.com/-Blog-) )

More info here:  
[http://www.sapphiresteel.com/The-Ruby-Connector-beta-now](http://www.sapphiresteel.com/The-Ruby-Connector-beta-now)  
[http://www.sapphiresteel.com/From-C-to-Ruby-and-back-again-The](http://www.sapphiresteel.com/From-C-to-Ruby-and-back-again-The)  
[http://www.sapphiresteel.com/Visual-Ruby-One-Small-Step](http://www.sapphiresteel.com/Visual-Ruby-One-Small-Step)

best wishes  
Huw

SapphireSteel Software  
[http://www.sapphiresteel.com](http://www.sapphiresteel.com)  
Ruby P.ming In Visual Studio
