This page last changed on Jul 12, 2005 by jflowers.
Summary

Describes ConsoleTester, a helper class that tests external process.

Description

When you need to test a console application, this task usually involves calling the application using Process.Start and monitoring that process. The helper class ConsoleTester (located in MbUnit.Core.Framework) is there to simplify this.

  • it redirects output and error streams so that they are logged in the report,
  • it checks the exit code,
  • a time out can be specified

Example

This example launches the MbUnit console application without any parameter or with various combinations:

using System;
 using MbUnit.Core.Framework;
 using MbUnit.Framework;
 
 namespace MyTests
 {
     [TestFixture]
     public class ConsoleTest
     {
         private ConsoleTester tester;
 
         [Test]
         public void NoArguments()
         {
             this.tester = new ConsoleTester("MbUnit.Cons.exe");
             this.tester.ExpectedExitCode = 0;
             this.tester.Run();
         } 
 
         [Test]
         public void Help()
         {
             this.tester = new ConsoleTester("MbUnit.Cons.exe","--help");
             this.tester.ExpectedExitCode = 0;
             this.tester.Run();
         }
     }
 }
Document generated by Confluence on Jun 11, 2007 11:56