1

I'd like to create a "fuzz test" for my wpf application where it gets to handle an onslaught of random user events.

Any idea on how this can be done. I see tools like Ranorex where i can automate Ui events to do test automation but i really want to do it randomly rather than orderly.

Thanks!

glutz
  • 1,889
  • 7
  • 29
  • 44

1 Answers1

2

You can write your own separate "Monkey Test" tool to do random clicks.

To do that, get the bounds of your window and then clicks to random coordinates inside of that Rectangle.

The code would look something like:

// 1) Find the process
var processes = Process.GetProcessByName("MyWPFApp");

// 2) Get handle to its window, find its bounds/rectangle
IntPtr handle = processes[0].MainWindowHandle;

RECT rect;
GetWindowRect(handle, out rect));

// 3) Send clicks to the window
SendClicksToRect(rect); //you will need to implement this method, 
// it will use mouse_event() as mentioned here: https://stackoverflow.com/questions/2416748/how-to-simulate-mouse-click-in-c

(NOTE that you will want to add error-checking, the code above does not do that)

Methods to use:

The advantage of writing your own is that you can customize it do follow scenarios[*] that your user would, thus hitting more code than just randomly clicking around.

[*] as in execute a scenario, and then do some random clicks

Community
  • 1
  • 1
canhazbits
  • 1,664
  • 1
  • 14
  • 19
  • are you suggesting to build this into my application? Also, how would i GET the bounds of my wpf window? – glutz May 02 '13 at 03:31
  • I'm suggesting this as a separate application. As for getting the bounds of the window I will update my answer. – canhazbits May 02 '13 at 17:25