- jonno_simpletestrunner_demo.zip
- Jonno Nunit Helper.AddIn
- Jonno.AddIns.Entities.dll
- Jonno.AddIns.Logic.VisualStudioSpecific.dll
- Jonno.AddIns.NunitHelper.dll
- Jonno.Extensions.dll
- Jonno.SimpleTestRunner.Entities.dll
- Jonno.SimpleTestRunner.exe
- Jonno.SimpleTestRunner.Logic.dll
- Jonno.Utilities.dll
- test framework helper options.xml
- jonno_simpletestrunner_src.zip
- Jonno Nunit Helper.AddIn
- Jonno.AddIns.Entities.UnitTests
- Jonno.AddIns.Entities
- Jonno.AddIns.Logic.EnvDTE
- Jonno.AddIns.NunitHelper
- Jonno.Extensions.UnitTests
- Jonno.Extensions
- Jonno.Logic.SimpleTestRunner
- Jonno.SimpleTestRunner.Entities
- Jonno.SimpleTestRunner
- Jonno.Utilities
- Nunit helper.sln
|
//-------------------------------------------------------------------------------------
// <copyright file='Program.cs' company='Jonno'>
// Copyright (c) Paul Johnson 2009 (email:paulmichael.johnson@gmail.com)
// Code is released under The Code Project Open License (CPOL).
// </copyright>
//-------------------------------------------------------------------------------------
namespace Jonno.SimpleTestRunner
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using Jonno.SimpleTestRunner.Logic;
public static class Program
{
/// <summary>
/// Runs a test using reflection so that Visual Studio can debug it.
/// The args must be in order:
/// args[0] = assembly path
/// args[1] = class name (without namespace)
/// args[2] = test method name
/// args[3] = framework to run on such as nunit
/// args[4] and above will be the assembly paths of the projects
/// </summary>
/// <param name="args">The arguments as outlined above.</param>
[STAThread]
public static void Main(string[] args)
{
try
{
// load all the projects into memory so that the debugger will enter them if required to
var list = new List<Assembly>();
for (int i = 4; i < args.Length; i++)
{
var assembly = Assembly.LoadFrom(args[i]);
if (assembly != null)
{
list.Add(assembly);
}
}
// set up the test run
var runner = new TestRunner(args[3]);
if (!runner.CreateTestClassInstance(args[0], args[1]))
{
MessageBox.Show(string.Format("Could not create instance of {0}.{1}", args[0], args[1]));
return;
}
int j = 0;
// wait for Visual Studio to attach to this process
// wait for three seconds before deciding that it won't happen
while (!Debugger.IsAttached)
{
j++;
Thread.Sleep(100);
if (j == 30)
{
MessageBox.Show("Could not attach to debugger.\r\nTry again.", "Try again.", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
Thread.Sleep(100);
// now a debugger is attached we can run the test
runner.RunTest(args[2], true);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("An exception of type {0} was thrown.\r\n{1}\r\n\r\n{2}", ex.GetType(), ex.Message, ex.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have over 15 years of development experience, in many different languages, programming styles and platforms. Currently working as a C# coder, and residing in north Herts in the UK. I love lean software development and anything that reduces a grind to leave more time for useful coding!