1

I know that you can create a separate console application, however, I am in the final stages of testing and my application does not have an interface. Is there a way to simply open a console and interact with that inside the desktop application? This would be in a test method. (I am using C#, in Visual Studio 2008).

Thanks,

badPanda

badpanda
  • 2,446
  • 5
  • 34
  • 45
  • In case anyone else is reading this, the solution I ended up using was to write directly to the debug window. However, AllocConsole and FreeConsole do work. – badpanda Jun 10 '10 at 23:12

2 Answers2

1

You might be able to do what you want using AllocConsole (creates a new console) or AttachConsole (attaches to an existing console), but I think there are some limitations to what you can do with them.

See here for the API documentation for AllocConsole and here's the PInvoke page.

Here's a list of lots of Console functions, might be something else useful there too.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116
1

This may or may not be helpful, but some of the same techniques of GUI testing can be applied to a console app too, of course.

Here is an article and example code in C# for a user interface test.

Or there are totally different tools/languages that can be used for UI testing, such as AutoIt v3, which is easy to learn and apply. AutoIt does have a DLL/COM control that you can access from your preferred programming language (but I haven't used it that way so I can't comment on how well it works).

ewall
  • 27,179
  • 15
  • 70
  • 84
  • I'm actually not doing any UI testing. The only piece of my application that involves the windows forms is a system tray icon. But thanks. – badpanda Jun 10 '10 at 21:59