+2003-10-12 Todd Berman <tberman@gentoo.org>\r
+\r
+ * Lots of files changed, upgraded to nunit 2.1.4. I built and ran the\r
+ corlib test, so it seems like existing tests should still work under\r
+ this new version of nunit.\r
+\r
2003-02-22 Martin Baulig <martin@ximian.com>\r
\r
* makefile(s): Added `MCS' and `MCS_FLAGS' variables.\r
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("2.0.9.001")]
+[assembly: AssemblyVersion("2.1.4.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
using System;
/// <summary>A set of Assert methods.</summary>
+ ///
+ //[Obsolete("use Assert class instead")]
public class Assertion
{
/// <summary>
/// <param name="condition">The evaluated condition</param>
static public void Assert(string message, bool condition)
{
- if (!condition)
- Assertion.Fail(message);
+ NUnit.Framework.Assert.IsTrue(condition, message);
}
/// <summary>
static public void AssertEquals(string message, int expected, int actual)
{
- if (expected != actual)
- Assertion.FailNotEquals(message, expected, actual);
+ NUnit.Framework.Assert.AreEqual(expected, actual, message);
}
/// <summary>Asserts that two doubles are equal concerning a delta.
static public void AssertEquals(string message, double expected,
double actual, double delta)
{
- // handle infinity specially since subtracting two infinite values gives
- // NaN and the following test fails
- if (double.IsInfinity(expected))
- {
- if (!(expected == actual))
- Assertion.FailNotEquals(message, expected, actual);
- }
- else if (!(Math.Abs(expected-actual) <= delta))
- Assertion.FailNotEquals(message, expected, actual);
+ NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
}
/// <summary>Asserts that two floats are equal concerning a delta.
static public void AssertEquals(string message, float expected,
float actual, float delta)
{
- // handle infinity specially since subtracting two infinite values gives
- // NaN and the following test fails
- if (float.IsInfinity(expected))
- {
- if (!(expected == actual))
- Assertion.FailNotEquals(message, expected, actual);
- }
- else if (!(Math.Abs(expected-actual) <= delta))
- Assertion.FailNotEquals(message, expected, actual);
+ NUnit.Framework.Assert.AreEqual(expected, actual, delta, message);
}
- /// <summary>
- /// Checks the type of the object, returning true if
- /// the object is a numeric type.
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- static private bool IsNumericType( Object obj )
- {
- if( null != obj )
- {
- if( obj is byte ) return true;
- if( obj is sbyte ) return true;
- if( obj is decimal ) return true;
- if( obj is double ) return true;
- if( obj is float ) return true;
- if( obj is int ) return true;
- if( obj is uint ) return true;
- if( obj is long ) return true;
- if( obj is short ) return true;
- if( obj is ushort ) return true;
-
- if( obj is System.Byte ) return true;
- if( obj is System.SByte ) return true;
- if( obj is System.Decimal ) return true;
- if( obj is System.Double ) return true;
- if( obj is System.Single ) return true;
- if( obj is System.Int32 ) return true;
- if( obj is System.UInt32 ) return true;
- if( obj is System.Int64 ) return true;
- if( obj is System.UInt64 ) return true;
- if( obj is System.Int16 ) return true;
- if( obj is System.UInt16 ) return true;
- }
- return false;
- }
-
- /// <summary>
- /// Used to compare numeric types. Comparisons between
- /// same types are fine (Int32 to Int32, or Int64 to Int64),
- /// but the Equals method fails across different types.
- /// This method was added to allow any numeric type to
- /// be handled correctly, by using <c>ToString</c> and
- /// comparing the result
- /// </summary>
- /// <param name="expected"></param>
- /// <param name="actual"></param>
- /// <returns></returns>
- static private bool ObjectsEqual( Object expected, Object actual )
- {
- if( IsNumericType( expected ) &&
- IsNumericType( actual ) )
- {
- //
- // Convert to strings and compare result to avoid
- // issues with different types that have the same
- // value
- //
- string sExpected = expected.ToString();
- string sActual = actual.ToString();
- return sExpected.Equals( sActual );
- }
- return expected.Equals(actual);
- }
-
/// <summary>
/// Asserts that two objects are equal. Two objects are considered
/// equal if both are null, or if both have the same value. Numeric
/// </summary>
static public void AssertEquals(string message, Object expected, Object actual)
{
- if (expected == null && actual == null)
- {
- return;
- }
- if (expected != null && actual != null )
- {
- if( ObjectsEqual( expected, actual ) )
- {
- return;
- }
- }
- Assertion.FailNotEquals(message, expected, actual);
+ NUnit.Framework.Assert.AreEqual(expected, actual, message);
}
/// <summary>Asserts that an object isn't null.</summary>
static public void AssertNotNull(Object anObject)
{
- Assertion.AssertNotNull(string.Empty, anObject);
+ NUnit.Framework.Assert.IsNotNull(anObject, string.Empty);
}
/// <summary>Asserts that an object isn't null.</summary>
static public void AssertNotNull(string message, Object anObject)
{
- Assertion.Assert(message, anObject != null);
+ NUnit.Framework.Assert.IsNotNull(anObject, message);
}
/// <summary>Asserts that an object is null.</summary>
static public void AssertNull(Object anObject)
{
- Assertion.AssertNull(string.Empty, anObject);
+ NUnit.Framework.Assert.IsNull(anObject, string.Empty);
}
/// <summary>Asserts that an object is null.</summary>
static public void AssertNull(string message, Object anObject)
{
- Assertion.Assert(message, anObject == null);
+ NUnit.Framework.Assert.IsNull(anObject, message);
}
/// <summary>Asserts that two objects refer to the same object. If they
/// </summary>
static public void AssertSame(Object expected, Object actual)
{
- Assertion.AssertSame(string.Empty, expected, actual);
+ NUnit.Framework.Assert.AreSame(expected, actual, string.Empty);
}
/// <summary>Asserts that two objects refer to the same object.
/// </summary>
static public void AssertSame(string message, Object expected, Object actual)
{
- if (expected == actual)
- return;
- Assertion.FailNotSame(message, expected, actual);
+ NUnit.Framework.Assert.AreSame(expected, actual, message);
}
/// <summary>Fails a test with no message.</summary>
static public void Fail()
{
- Assertion.Fail(string.Empty);
+ NUnit.Framework.Assert.Fail();
}
/// <summary>Fails a test with the given message.</summary>
static public void Fail(string message)
{
- if (message == null)
- message = string.Empty;
- throw new AssertionException(message);
- }
-
- /// <summary>
- /// Called when two objects have been compared and found to be
- /// different.
- /// </summary>
- /// <param name="message"></param>
- /// <param name="expected"></param>
- /// <param name="actual"></param>
- static private void FailNotEquals(string message, Object expected, Object actual)
- {
- Assertion.Fail(
- AssertionFailureMessage.FormatMessageForFailNotEquals(
- message,
- expected,
- actual) );
- }
-
- static private void FailNotSame(string message, Object expected, Object actual)
- {
- string formatted=string.Empty;
- if (message != null)
- formatted= message+" ";
- Assertion.Fail(formatted+"expected same");
+ NUnit.Framework.Assert.Fail(message);
}
}
}
\ No newline at end of file
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig, Douglas de la Torre
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig, Douglas de la Torre
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
-' Copyright © 2001 Douglas de la Torre
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
+' Copyright 2001 Douglas de la Torre
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig, or Copyright © 2001 Douglas de la Torre
+' Portions Copyright 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
+' Copyright 2000-2002 Philip A. Craig, or Copyright 2001 Douglas de la Torre
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
{
get
{
- return "\r\n";
+ return "\r\n\t";
}
}
{
sbOutput.Append( NewLine );
sbOutput.Append( ExpectedText() );
- sbOutput.Append( (expected != null) ? expected : "(null)" );
+ sbOutput.Append( DisplayString( expected ) );
sbOutput.Append( ">" );
sbOutput.Append( NewLine );
sbOutput.Append( ButWasText() );
- sbOutput.Append( (actual != null) ? actual : "(null)" );
+ sbOutput.Append( DisplayString( actual ) );
sbOutput.Append( ">" );
}
+ static protected string DisplayString( object obj )
+ {
+ if ( obj == null )
+ return "(null)";
+ else if ( obj is string )
+ return Quoted( (string)obj );
+ else
+ return obj.ToString();
+ }
+
+ static protected string Quoted( string text )
+ {
+ return string.Format( "\"{0}\"", text );
+ }
+
/// <summary>
/// Draws a marker under the expected/actual strings that highlights
/// where in the string a mismatch occurred.
//
// Same strings
//
- Assertion.Assert( sExpected.Equals( sActual ) );
+ Assert.IsTrue( sExpected.Equals( sActual ) );
return -1;
}
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <returns></returns>
- static public string FormatMessageForFailNotEquals(string message, Object expected, Object actual)
+ static public string FormatMessageForFailNotEquals(Object expected, Object actual, string message)
{
StringBuilder sbOutput = CreateStringBuilder( message );
if( null != message )
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
public sealed class ExpectedExceptionAttribute : Attribute
{
private Type expectedException;
+ private string expectedMessage;
public ExpectedExceptionAttribute(Type exceptionType)
{
expectedException = exceptionType;
}
+ public ExpectedExceptionAttribute(Type exceptionType, string expectedMessage)
+ {
+ expectedException = exceptionType;
+ this.expectedMessage = expectedMessage;
+ }
+
public Type ExceptionType
{
get{ return expectedException; }
set{ expectedException = value; }
}
-}
+ public string ExpectedMessage
+ {
+ get { return expectedMessage; }
+ set { expectedMessage = value; }
+ }
+ }
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
public class ExpectedExceptionTestCase : TemplateTestCase
{
private Type expectedException;
+ private string expectedMessage;
- public ExpectedExceptionTestCase(object fixture, MethodInfo info, Type expectedException)
+ public ExpectedExceptionTestCase(object fixture, MethodInfo info, Type expectedException, string expectedMessage)
: base(fixture, info)
{
this.expectedException = expectedException;
+ this.expectedMessage = expectedMessage;
}
protected override internal void ProcessException(Exception exception, TestCaseResult testResult)
{
if (expectedException.Equals(exception.GetType()))
{
- testResult.Success();
+ if (expectedMessage != null && !expectedMessage.Equals(exception.Message))
+ {
+ string message = string.Format("Expected exception to have message: \" {0} \" but recieved message \" {1}\" ",
+ expectedMessage, exception.Message);
+ testResult.Failure(message, exception.StackTrace);
+ }
+ else
+ {
+ testResult.Success();
+ }
}
else
{
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'***********************************************************************************/
#endregion
-
namespace NUnit.Framework
{
using System;
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
using System;
namespace NUnit.Core
./AssemblyInfo.cs
+./Assert.cs
./Assertion.cs
./AssertionException.cs
./AssertionFailureMessage.cs
./IgnoreAttribute.cs
./InvalidFixture.cs
./InvalidSuiteException.cs
+./ITest.cs
./InvalidTestFixtureException.cs
./LongLivingMarshalByRefObject.cs
./NoTestFixturesException.cs
./RemoteTestRunner.cs
./ResultSummarizer.cs
./ResultVisitor.cs
+./RootTestSuite.cs
./SetUpAttribute.cs
./StackTraceFilter.cs
+./StringTextWriter.cs
./SuiteAttribute.cs
./SummaryVisitor.cs
./TearDownAttribute.cs
./TemplateTestCase.cs
./Test.cs
./TestAttribute.cs
+./TestAssembly.cs
./TestCase.cs
./TestCaseBuilder.cs
./TestCaseResult.cs
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
protected internal override void ProcessException(Exception exception, TestCaseResult testResult)
{
- if(exception is NUnit.Framework.AssertionException)
- {
- NUnit.Framework.AssertionException error = (NUnit.Framework.AssertionException)exception;
- testResult.Failure(error.Message, error.StackTrace);
- }
- else
- {
- testResult.Failure(exception.Message, exception.StackTrace);
- }
+ RecordException( exception, testResult );
}
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
if (method.IsAbstract)
reason = "it must not be abstract";
+ else if (method.IsStatic)
+ reason = "it must be an instance method";
else if (!method.IsPublic)
reason = "it must be a public method";
else if (method.GetParameters().Length != 0)
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
{
using System;
using System.IO;
+ using System.Collections;
using System.Reflection;
using System.Runtime.Remoting;
[Serializable]
public class RemoteTestRunner : LongLivingMarshalByRefObject
{
+ #region Instance variables
+
+ /// <summary>
+ /// The loaded test suite
+ /// </summary>
private TestSuite suite;
- private string fullName;
- private string assemblyName;
- public void Initialize(string assemblyName)
+ /// <summary>
+ /// The test Fixture name to load
+ /// </summary>
+ private string testName;
+
+ /// <summary>
+ /// The test file to load. If assemblies is null,
+ /// this must be an assembly file, otherwise it
+ /// is only used to provide a name for the root
+ /// test node having the assemblies as children.
+ /// </summary>
+ private string testFileName;
+
+ /// <summary>
+ /// The list of assemblies to load
+ /// </summary>
+ private IList assemblies;
+
+ #endregion
+
+ #region Properties
+
+ public string TestName
+ {
+ get { return testName; }
+ set { testName = value; }
+ }
+
+ public Test Test
+ {
+ get { return suite; }
+ }
+
+ public string TestFileName
{
- this.assemblyName = assemblyName;
+ get { return testFileName; }
+ set { testFileName = value; }
}
- public void Initialize(string fixtureName, string assemblyName)
+ public IList Assemblies
{
- TestName = fixtureName;
- Initialize(assemblyName);
+ get { return assemblies; }
+ set { assemblies = value; }
}
+ #endregion
+
+ #region Public Methods
+
public void BuildSuite()
{
TestSuiteBuilder builder = new TestSuiteBuilder();
- if(fullName == null)
- suite = builder.Build(assemblyName);
+
+ if(testName == null )
+ if ( assemblies == null )
+ suite = builder.Build( testFileName );
+ else
+ suite = builder.Build( testFileName, assemblies );
else
- suite = builder.Build(fullName, assemblyName);
+ if ( assemblies == null )
+ suite = builder.Build( testFileName, testName );
+ else
+ suite = builder.Build( assemblies, testName );
if(suite != null) TestName = suite.FullName;
}
public TestResult Run(NUnit.Core.EventListener listener, TextWriter outText, TextWriter errorText)
{
- Console.SetOut(new StringTextWriter(outText));
- Console.SetError(new StringTextWriter(errorText));
+ BufferedStringTextWriter outBuffer = new BufferedStringTextWriter( outText );
+ BufferedStringTextWriter errorBuffer = new BufferedStringTextWriter( errorText );
- Test test = FindByName(suite, fullName);
+ Console.SetOut( outBuffer );
+ Console.SetError( errorBuffer );
- TestResult result = test.Run(listener);
+ Test test = FindByName(suite, testName);
- return result;
- }
+ string currentDirectory = Environment.CurrentDirectory;
- /// <summary>
- /// Use this wrapper to ensure that only strings get passed accross the AppDomain
- /// boundry. Otherwise tests will break when non-remotable objecs are passed to
- /// Console.Write/WriteLine.
- /// </summary>
- private class StringTextWriter : TextWriter
- {
- public StringTextWriter(TextWriter aTextWriter)
- {
- theTextWriter = aTextWriter;
- }
- private TextWriter theTextWriter;
+ string assemblyName = assemblies == null ? testFileName : (string)assemblies[test.AssemblyKey];
+ string assemblyDirectory = Path.GetDirectoryName( assemblyName );
- override public void Write(char aChar)
- {
- theTextWriter.Write(aChar);
- }
+ if ( assemblyDirectory != null && assemblyDirectory != string.Empty )
+ Environment.CurrentDirectory = assemblyDirectory;
- override public void Write(string aString)
- {
- theTextWriter.Write(aString);
- }
+ TestResult result = test.Run(listener);
- override public void WriteLine(string aString)
- {
- theTextWriter.WriteLine(aString);
- }
+ Environment.CurrentDirectory = currentDirectory;
- override public System.Text.Encoding Encoding
- {
- get { return theTextWriter.Encoding; }
- }
+ outBuffer.Close();
+ errorBuffer.Close();
+
+ return result;
}
+ #endregion
+
+ #region FindByName Helper
+
private Test FindByName(Test test, string fullName)
{
+ if(test.UniqueName.Equals(fullName)) return test;
if(test.FullName.Equals(fullName)) return test;
Test result = null;
return result;
}
-
- public string TestName
- {
- get { return fullName; }
- set { fullName = value; }
- }
-
- public Test Test
- {
- get
- { return suite; }
- }
}
+
+ #endregion
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
/// </summary>
public interface ResultVisitor
{
- void visit(TestCaseResult caseResult);
- void visit(TestSuiteResult suiteResult);
+ void Visit(TestCaseResult caseResult);
+ void Visit(TestSuiteResult suiteResult);
}
}
<xs:element name="reason" type="reasonType" minOccurs="0" />
</xs:choice>
<xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="description" type="xs:string" use="optional" />
<xs:attribute name="success" type="xs:string" use="optional" />
<xs:attribute name="time" type="xs:string" use="optional" />
<xs:attribute name="executed" type="xs:string" use="required" />
<xs:element name="results" type="resultsType" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="description" type="xs:string" use="optional" />
<xs:attribute name="success" type="xs:string" use="required" />
<xs:attribute name="time" type="xs:string" use="required" />
</xs:complexType>
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
"NUnit.Core.TemplateTestCase",
"NUnit.Core.TestResult",
"NUnit.Core.TestSuite",
- "NUnit.Framework.Assertion"
+ "NUnit.Framework.Assertion",
+ "NUnit.Framework.Assert"
};
for (int i = 0; i < patterns.Length; i++)
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
<xsl:if test="//test-case[@executed='False']"><xsl:text>Tests not run:
</xsl:text></xsl:if>
<xsl:apply-templates select="//test-case[@executed='False']"/>
-<xsl:text disable-output-escaping='yes'>
</xsl:text>
+<xsl:text disable-output-escaping='yes'>
</xsl:text>
</xsl:template>
<xsl:template match="test-case">
<xsl:value-of select="@name"/>
<xsl:text> : </xsl:text>
<xsl:value-of select="child::node()/message"/>
-<xsl:text disable-output-escaping='yes'>
</xsl:text>
+<xsl:text disable-output-escaping='yes'>
</xsl:text>
<xsl:if test="failure">
<xsl:value-of select="failure/stack-trace"/>
<xsl:text>
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
initialized = false;
}
- public void visit(TestCaseResult caseResult)
+ public void Visit(TestCaseResult caseResult)
{
SetNameandTime(caseResult.Name, caseResult.Time);
testsNotRun++;
}
- public void visit(TestSuiteResult suiteResult)
+ public void Visit(TestSuiteResult suiteResult)
{
SetNameandTime(suiteResult.Name, suiteResult.Time);
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
namespace NUnit.Core
{
using System;
+ using System.Text;
using System.Reflection;
/// <summary>
private object fixture;
private MethodInfo method;
+
public TemplateTestCase(object fixture, MethodInfo method) : base(fixture.GetType().FullName, method.Name)
{
this.fixture = fixture;
this.method = method;
}
- public override void Run(TestCaseResult testResult)
+ private bool suiteRunning
+ {
+ get
+ {
+ return (Suite != null && Suite.SuiteRunning);
+ }
+ }
+
+ public override void Run(TestCaseResult testResult )
{
if(ShouldRun)
{
#if NUNIT_LEAKAGE_TEST
long before = System.GC.GetTotalMemory( true );
#endif
+ bool setupComplete = false;
try
{
+ if ( !suiteRunning ) InvokeTestFixtureSetUp();
InvokeSetUp();
+ setupComplete = true;
InvokeTestCase();
ProcessNoException(testResult);
}
catch(NunitException exception)
{
- ProcessException(exception.InnerException, testResult);
+ if ( setupComplete )
+ ProcessException(exception.InnerException, testResult);
+ else
+ RecordException( exception.InnerException, testResult );
}
catch(Exception exp)
{
- ProcessException(exp, testResult);
+ if ( setupComplete )
+ ProcessException(exp, testResult);
+ else
+ RecordException( exp, testResult );
}
finally
{
}
catch(NunitException exception)
{
- ProcessException(exception.InnerException, testResult);
+ RecordException(exception.InnerException, testResult, true);
}
catch(Exception exp)
{
- ProcessException(exp, testResult);
+ RecordException(exp, testResult, true);
}
+
+ if ( !suiteRunning ) InvokeTestFixtureTearDown();
DateTime stop = DateTime.Now;
TimeSpan span = stop.Subtract(start);
return;
}
+ protected void RecordException( Exception exception, TestCaseResult testResult )
+ {
+ RecordException( exception, testResult, false );
+ }
+
+ protected void RecordException( Exception exception, TestCaseResult testResult, bool inTearDown )
+ {
+ StringBuilder msg = new StringBuilder();
+ StringBuilder st = new StringBuilder();
+
+ if ( inTearDown )
+ {
+ msg.Append( testResult.Message );
+ msg.Append( Environment.NewLine );
+ msg.Append( "TearDown : " );
+ st.Append( testResult.StackTrace );
+ st.Append( Environment.NewLine );
+ st.Append( "--TearDown" );
+ st.Append( Environment.NewLine );
+ }
+
+ msg.Append( BuildMessage( exception ) );
+ st.Append( BuildStackTrace( exception ) );
+ testResult.Failure( msg.ToString(), st.ToString() );
+ }
+
+ private string BuildMessage(Exception exception)
+ {
+ StringBuilder sb = new StringBuilder();
+ if ( exception is NUnit.Framework.AssertionException )
+ sb.Append( exception.Message );
+ else
+ sb.AppendFormat( "{0} : {1}", exception.GetType().ToString(), exception.Message );
+
+ Exception inner = exception.InnerException;
+ while( inner != null )
+ {
+ sb.Append( Environment.NewLine );
+ sb.AppendFormat( " ----> {0} : {1}", inner.GetType().ToString(), inner.Message );
+ inner = inner.InnerException;
+ }
+
+ return sb.ToString();
+ }
+
+ private string BuildStackTrace(Exception exception)
+ {
+ if(exception.InnerException!=null)
+ return exception.StackTrace + Environment.NewLine +
+ "--" + exception.GetType().Name + Environment.NewLine +
+ BuildStackTrace(exception.InnerException);
+ else
+ return exception.StackTrace;
+ }
+
+ private void InvokeTestFixtureTearDown()
+ {
+ MethodInfo method = FindTestFixtureTearDownMethod(fixture);
+ if(method != null)
+ {
+ InvokeMethod(method, fixture);
+ }
+ }
+
private void InvokeTearDown()
{
MethodInfo method = FindTearDownMethod(fixture);
return FindMethodByAttribute(fixture, typeof(NUnit.Framework.TearDownAttribute));
}
+ private MethodInfo FindTestFixtureTearDownMethod(object fixture)
+ {
+ return FindMethodByAttribute(fixture, typeof(NUnit.Framework.TestFixtureTearDownAttribute));
+ }
+
+ private void InvokeTestFixtureSetUp()
+ {
+ MethodInfo method = FindTestFixtureSetUpMethod(fixture);
+ if(method != null)
+ {
+ InvokeMethod(method, fixture);
+ }
+ }
+
private void InvokeSetUp()
{
MethodInfo method = FindSetUpMethod(fixture);
}
}
+ private MethodInfo FindTestFixtureSetUpMethod(object fixture)
+ {
+ return FindMethodByAttribute(fixture, typeof(NUnit.Framework.TestFixtureSetUpAttribute));
+ }
+
private MethodInfo FindSetUpMethod(object fixture)
{
return FindMethodByAttribute(fixture, typeof(NUnit.Framework.SetUpAttribute));
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
/// <summary>
/// Test Class.
/// </summary>
- public abstract class Test : LongLivingMarshalByRefObject, TestInfo
+ public abstract class Test : LongLivingMarshalByRefObject, ITest, IComparable
{
private string fullName;
private string testName;
+ private int assemblyKey;
private bool shouldRun;
private string ignoreReason;
+ private string description;
- protected Test(string pathName, string testName)
+ public Test( string name ) : this( name, 0 ) { }
+
+ public Test( string name, int assemblyKey )
+ {
+ fullName = testName = name;
+ this.assemblyKey = assemblyKey;
+ }
+
+ protected Test( string pathName, string testName )
+ : this( pathName, testName, 0 ) { }
+
+ protected Test( string pathName, string testName, int assemblyKey )
{
fullName = pathName + "." + testName;
this.testName = testName;
+ this.assemblyKey = assemblyKey;
shouldRun = true;
}
set { ignoreReason = value; }
}
- public bool ShouldRun
+ public virtual bool ShouldRun
{
get { return shouldRun; }
set { shouldRun = value; }
}
- public Test(string name)
+ public String Description
{
- fullName = testName = name;
+ get { return description; }
+ set { description = value; }
}
public string FullName
get { return testName; }
}
+ /// <summary>
+ /// If the name is a path, this just returns the file part
+ /// </summary>
+ public string ShortName
+ {
+ get
+ {
+ string name = Name;
+ int val = name.LastIndexOf("\\");
+ if(val != -1)
+ name = name.Substring(val+1);
+ return name;
+ }
+ }
+
+ public int AssemblyKey
+ {
+ get { return assemblyKey; }
+ set { assemblyKey = value; }
+ }
+
+ public string UniqueName
+ {
+ get { return string.Format( "[{0}]{1}", assemblyKey, fullName ); }
+ }
+
public abstract int CountTestCases { get; }
public abstract bool IsSuite { get; }
+ public abstract bool IsFixture{ get; }
+ public abstract bool IsTestCase{ get; }
public abstract ArrayList Tests { get; }
-
+
public abstract TestResult Run(EventListener listener);
protected MethodInfo FindMethodByAttribute(object fixture, Type type)
}
}
}
+
+ #region IComparable Members
+
+ public int CompareTo(object obj)
+ {
+ Test other = obj as Test;
+
+ if ( other == null )
+ return -1;
+
+ return this.FullName.CompareTo( other.FullName );
+ }
+
+ #endregion
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov,
+' Charlie Poole or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
namespace NUnit.Framework
{
using System;
+
/// <summary>
- /// TestAttribute.
+ /// Adding this attribute to a method within a <seealso cref="TestFixtureAttribute"/>
+ /// class makes the method callable from the NUnit test runner. There is a property
+ /// called Description which is optional which you can provide a more detailed test
+ /// description. This class cannot be inherited.
/// </summary>
///
+ /// <example>
+ /// [TestFixture]
+ /// public class Fixture
+ /// {
+ /// [Test]
+ /// public void MethodToTest()
+ /// {}
+ ///
+ /// [Test(Description = "more detailed description")]
+ /// publc void TestDescriptionMethod()
+ /// {}
+ /// }
+ /// </example>
+ ///
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public sealed class TestAttribute : Attribute
- {}
+ {
+ private string description;
+
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+ }
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
get { return 1; }
}
+ private TestSuite suite;
+
+ public TestSuite Suite
+ {
+ get { return suite; }
+ set { suite = value; }
+ }
+
public override TestResult Run(EventListener listener)
{
TestCaseResult testResult = new TestCaseResult(this);
get { return false; }
}
+ public override bool IsFixture
+ {
+ get { return false; }
+ }
+
+ public override bool IsTestCase
+ {
+ get { return true; }
+ }
+
public override ArrayList Tests
{
get { return null; }
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
{
TestCase testCase = null;
- if(HasTestAttribute(method) || HasObsoleteTestName(method))
+ if(HasTestAttribute(method) || HasObsoleteTestName(method) && !HasAnySetUpOrTearDownAttribute(method) )
{
if(IsTestMethodSignatureCorrect(method))
{
testCase = new NormalTestCase(fixture, method);
else
{
- Type expectedException = GetExpectedExceptions(method);
- testCase = new ExpectedExceptionTestCase(fixture, method, expectedException);
+ NUnit.Framework.ExpectedExceptionAttribute expectedException = GetExpectedExceptions(method);
+ testCase = new ExpectedExceptionTestCase(fixture, method, expectedException.ExceptionType, expectedException.ExpectedMessage);
}
+
if(HasIgnoreAttribute(method))
{
testCase.ShouldRun = false;
testCase.IgnoreReason = GetIgnoreReason(method);
}
+ testCase.Description = GetDescription(method);
}
else
{
- // string reason = String.Format("Method: {0}'s signature is not correct", method.Name);
- // testCase = new NotRunnableTestCase(method, reason);
testCase = new NotRunnableTestCase(method);
}
}
return attributes.Length == 1;
}
- private static Type GetExpectedExceptions(MethodInfo method)
+ private static NUnit.Framework.ExpectedExceptionAttribute GetExpectedExceptions(MethodInfo method)
{
Type exceptionAttr = typeof(NUnit.Framework.ExpectedExceptionAttribute);
object[] attributes = method.GetCustomAttributes(exceptionAttr, false);
- Type returnType = null;
+ NUnit.Framework.ExpectedExceptionAttribute expectedAttr = null;
+
+ if(attributes.Length == 1)
+ {
+ expectedAttr = (NUnit.Framework.ExpectedExceptionAttribute)attributes[0];
+ }
+
+ return expectedAttr;
+ }
+
+ private static string GetDescription(MethodInfo method)
+ {
+ Type testAttr = typeof(NUnit.Framework.TestAttribute);
+ object[] attributes = method.GetCustomAttributes(testAttr, false);
+
+ string description = null;
if(attributes.Length == 1)
{
- NUnit.Framework.ExpectedExceptionAttribute expectedAttr =
- (NUnit.Framework.ExpectedExceptionAttribute)attributes[0];
- returnType = expectedAttr.ExceptionType;
+ NUnit.Framework.TestAttribute attribute =
+ (NUnit.Framework.TestAttribute)attributes[0];
+ description = attribute.Description;
}
- return returnType;
+ return description;
}
+
public static int CountTestCases(object fixture)
{
int testCases = 0;
private static bool IsTestMethodSignatureCorrect(MethodInfo methodToCheck)
{
return
- !methodToCheck.IsAbstract
+ !methodToCheck.IsStatic
+ && !methodToCheck.IsAbstract
&& methodToCheck.IsPublic
&& methodToCheck.GetParameters().Length == 0
&& methodToCheck.ReturnType.Equals(typeof(void));
return methodToCheck.Name.ToLower().StartsWith("test");
}
+ private static bool HasAnySetUpOrTearDownAttribute( MethodInfo methodToCheck )
+ {
+ object[] attributes = methodToCheck.GetCustomAttributes( false );
+ foreach( Attribute attribute in attributes )
+ if ( attribute is NUnit.Framework.SetUpAttribute ||
+ attribute is NUnit.Framework.TestFixtureSetUpAttribute ||
+ attribute is NUnit.Framework.TearDownAttribute ||
+ attribute is NUnit.Framework.TestFixtureTearDownAttribute )
+ return true;
+
+ return false;
+ }
+
private static bool HasIgnoreAttribute(MethodInfo methodToCheck)
{
Type ignoreMethodAttribute = typeof(NUnit.Framework.IgnoreAttribute);
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
public class TestCaseResult : TestResult
{
private string message;
- private string stackTrace;
+
- public TestCaseResult(TestCase testCase):base(testCase, testCase.FullName)
+ public TestCaseResult(ITest testCase):base(testCase, testCase.FullName)
{
Executed = false;
}
Executed = true;
IsFailure = true;
this.message = message;
- this.stackTrace = stackTrace;
+ StackTrace = stackTrace;
}
public override string Message
get { return message; }
}
- public override string StackTrace
- {
- get
- {
- return stackTrace;
- }
- }
-
public override string ToString()
{
StringBuilder builder = new StringBuilder();
public override void Accept(ResultVisitor visitor)
{
- visitor.visit(this);
+ visitor.Visit(this);
}
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
using System;
-namespace NUnit.Framework
+namespace NUnit.Core
{
- using NUnit.Core;
using System.Runtime.Remoting;
using System.Security.Policy;
using System.Reflection;
using System.Configuration;
using System.IO;
- /// <summary>
- /// Summary description for TestDomain.
- /// </summary>
public class TestDomain
{
- private string assemblyName;
+ #region Instance Variables
+
+ /// <summary>
+ /// The appdomain used to load tests
+ /// </summary>
private AppDomain domain;
+
+ /// <summary>
+ /// The path to our cache
+ /// </summary>
private string cachePath;
+
+ /// <summary>
+ /// The remote runner loaded in the test appdomain
+ /// </summary>
private RemoteTestRunner testRunner;
- private TextWriter outStream;
- private TextWriter errorStream;
- public TestDomain(TextWriter outStream, TextWriter errorStream)
+ #endregion
+
+ #region Properties
+
+ public bool IsTestLoaded
{
- this.outStream = outStream;
- this.errorStream = errorStream;
+ get { return testRunner != null; }
}
- private void ThrowIfAlreadyLoaded()
+ public Test Test
{
- if ( domain != null || testRunner != null )
- throw new InvalidOperationException( "TestDomain already loaded" );
+ get { return IsTestLoaded ? testRunner.Test : null; }
}
- public Test Load(string assemblyFileName)
+ public string TestName
{
- ThrowIfAlreadyLoaded();
+ get { return testRunner.TestName; }
+ set { testRunner.TestName = value; }
+ }
+
+ #endregion
+
+ #region Public Members
- assemblyName = assemblyFileName;
- FileInfo file = new FileInfo(assemblyFileName);
+ #region Load a single assembly
+
+ public Test LoadAssembly( string assemblyFileName )
+ {
+ return LoadAssembly( assemblyFileName, null );
+ }
+
+ public Test LoadAssembly(string assemblyFileName, string testFixture)
+ {
+ FileInfo testFile = new FileInfo( assemblyFileName );
+
+ ThrowIfAlreadyLoaded();
try
{
- domain = MakeAppDomain(file);
- testRunner = MakeRemoteTestRunner(file, domain);
- return testRunner.Test;
+ string assemblyPath = Path.GetFullPath( assemblyFileName );
+
+ string domainName = string.Format( "domain-{0}", Path.GetFileName( assemblyFileName ) );
+ domain = MakeAppDomain( domainName, testFile.DirectoryName, testFile.FullName + ".config", testFile.DirectoryName );
+ testRunner = MakeRemoteTestRunner( domain );
+
+ if(testRunner != null)
+ {
+ testRunner.TestFileName = assemblyPath;
+ if ( testFixture != null )
+ testRunner.TestName = testFixture;
+ domain.DoCallBack( new CrossAppDomainDelegate( testRunner.BuildSuite ) );
+ return testRunner.Test;
+ }
+ else
+ {
+ Unload();
+ return null;
+ }
}
- catch (Exception e)
+ catch
{
Unload();
- throw e;
+ throw;
}
}
- public Test Load(string testFixture, string assemblyFileName)
+ #endregion
+
+ #region Load multiple assemblies
+
+ public Test LoadAssemblies( string testFileName, IList assemblies )
{
- ThrowIfAlreadyLoaded();
+ return LoadAssemblies( testFileName, assemblies, null );
+ }
+
+ public Test LoadAssemblies( string testFileName, IList assemblies, string testFixture )
+ {
+ FileInfo testFile = new FileInfo( testFileName );
+ return LoadAssemblies( testFileName, testFile.DirectoryName, testFile.FullName + ".config", GetBinPath(assemblies), assemblies, testFixture );
+ }
- assemblyName = assemblyFileName;
- FileInfo file = new FileInfo(assemblyFileName);
+ public Test LoadAssemblies( string testFileName, string appBase, string configFile, string binPath, IList assemblies, string testFixture )
+ {
+ ThrowIfAlreadyLoaded();
try
{
- domain = MakeAppDomain(file);
+ string domainName = string.Format( "domain-{0}", Path.GetFileName( testFileName ) );
+ domain = MakeAppDomain( testFileName, appBase, configFile, binPath );
+ testRunner = MakeRemoteTestRunner( domain );
- testRunner = (
- RemoteTestRunner) domain.CreateInstanceAndUnwrap(
- typeof(RemoteTestRunner).Assembly.FullName,
- typeof(RemoteTestRunner).FullName,
- false, BindingFlags.Default,null,null,null,null,null);
-
if(testRunner != null)
{
- testRunner.Initialize(testFixture, file.FullName);
- domain.DoCallBack(new CrossAppDomainDelegate(testRunner.BuildSuite));
+ testRunner.TestFileName = testFileName;
+ testRunner.Assemblies = assemblies;
+ if ( testFixture != null )
+ testRunner.TestName = testFixture;
+ domain.DoCallBack( new CrossAppDomainDelegate( testRunner.BuildSuite ) );
return testRunner.Test;
}
else
return null;
}
}
- catch (Exception e)
+ catch
{
Unload();
- throw e;
+ throw;
}
}
- public string AssemblyName
- {
- get { return assemblyName; }
- }
+ #endregion
- public string TestName
- {
- get { return testRunner.TestName; }
- set { testRunner.TestName = value; }
- }
-
- public TestResult Run(NUnit.Core.EventListener listener)
+ public TestResult Run(NUnit.Core.EventListener listener, TextWriter outStream, TextWriter errorStream )
{
return testRunner.Run(listener, outStream, errorStream);
}
if(domain != null)
{
- AppDomain.Unload(domain);
- DirectoryInfo cacheDir = new DirectoryInfo(cachePath);
- if(cacheDir.Exists) cacheDir.Delete(true);
+ try
+ {
+ AppDomain.Unload(domain);
+ DirectoryInfo cacheDir = new DirectoryInfo(cachePath);
+ if(cacheDir.Exists) cacheDir.Delete(true);
+ }
+ catch( CannotUnloadAppDomainException )
+ {
+ // TODO: Do something useful. For now we just
+ // leave the orphaned AppDomain "out there"
+ // rather than aborting the application.
+ }
+ finally
+ {
+ domain = null;
+ }
}
- domain = null;
}
- private AppDomain MakeAppDomain(FileInfo file)
- {
- AppDomainSetup setup = new AppDomainSetup();
- setup.ApplicationBase = Directory.GetDirectoryRoot(file.DirectoryName);
- setup.PrivateBinPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase
- + ";" + file.DirectoryName;
- setup.ApplicationName = "Tests";
-
- setup.ShadowCopyFiles = "true";
- setup.ShadowCopyDirectories = file.DirectoryName;
+ #endregion
+ #region Helper Methods
- setup.ConfigurationFile = file.DirectoryName + @"\" +
- file.Name + ".config";
+ private void ThrowIfAlreadyLoaded()
+ {
+ if ( domain != null || testRunner != null )
+ throw new InvalidOperationException( "TestDomain already loaded" );
+ }
+ /// <summary>
+ /// This method creates appDomains for the framework.
+ /// </summary>
+ /// <param name="domainName">Name of the domain</param>
+ /// <param name="appBase">ApplicationBase for the domain</param>
+ /// <param name="configFile">ConfigurationFile for the domain</param>
+ /// <param name="binPath">PrivateBinPath for the domain</param>
+ /// <returns></returns>
+ private AppDomain MakeAppDomain( string domainName, string appBase, string configFile, string binPath )
+ {
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence);
- string domainName = String.Format("domain-{0}", file.Name);
+ AppDomainSetup setup = new AppDomainSetup();
+
+ // We always use the same application name
+ setup.ApplicationName = "Tests";
+ // We always want to do shadow copying. Note that we do NOT
+ // set ShadowCopyDirectories because we rely on the default
+ // setting of ApplicationBase plus PrivateBinPath
+ setup.ShadowCopyFiles = "true";
+ setup.ShadowCopyDirectories = appBase;
+
+ setup.ApplicationBase = appBase;
+ setup.ConfigurationFile = configFile;
+ setup.PrivateBinPath = binPath;
+
AppDomain runnerDomain = AppDomain.CreateDomain(domainName, evidence, setup);
+
ConfigureCachePath(runnerDomain);
+
return runnerDomain;
}
+ /// <summary>
+ /// Set the location for caching and delete any old cache info
+ /// </summary>
+ /// <param name="domain">Our domain</param>
private void ConfigureCachePath(AppDomain domain)
{
cachePath = String.Format(@"{0}\{1}",
return;
}
- private static RemoteTestRunner MakeRemoteTestRunner(FileInfo file, AppDomain runnerDomain)
+ private static RemoteTestRunner MakeRemoteTestRunner( AppDomain runnerDomain )
{
- RemoteTestRunner runner = (
- RemoteTestRunner) runnerDomain.CreateInstanceAndUnwrap(
+ object obj = runnerDomain.CreateInstanceAndUnwrap(
typeof(RemoteTestRunner).Assembly.FullName,
typeof(RemoteTestRunner).FullName,
- true, BindingFlags.Default,null,null,null,null,null);
- if(runner != null)
+ false, BindingFlags.Default,null,null,null,null,null);
+
+ return (RemoteTestRunner) obj;
+ }
+
+ public static string GetBinPath( IList assemblies )
+ {
+ ArrayList dirs = new ArrayList();
+ string binPath = null;
+
+ foreach( string path in assemblies )
{
- runner.Initialize(file.FullName);
- runnerDomain.DoCallBack(new CrossAppDomainDelegate(runner.BuildSuite));
+ string dir = Path.GetDirectoryName( Path.GetFullPath( path ) );
+ if ( !dirs.Contains( dir ) )
+ {
+ dirs.Add( dir );
+
+ if ( binPath == null )
+ binPath = dir;
+ else
+ binPath = binPath + ";" + dir;
+ }
}
- return runner;
+
+ return binPath;
}
+
+ #endregion
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
/// </example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class TestFixtureAttribute : Attribute
- {}
-}
\ No newline at end of file
+ {
+ private string description;
+
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+ }
+
+}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
private bool isFailure;
private double time;
private string name;
- private TestInfo test;
+ private ITest test;
+ private string stackTrace;
+ private string description;
#if NUNIT_LEAKAGE_TEST
private long leakage = 0;
#endif
- protected TestResult(TestInfo test, string name)
+ protected TestResult(ITest test, string name)
{
this.name = name;
this.test = test;
+ if(test != null)
+ this.description = test.Description;
}
public bool Executed
set { executed = value; }
}
+ public virtual bool AllTestsExecuted
+ {
+ get { return executed; }
+ }
+
public virtual string Name
{
get{ return name;}
}
- public TestInfo Test
+ public ITest Test
{
get{ return test;}
}
set { isFailure = value; }
}
+ public virtual string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+
public double Time
{
get{ return time; }
get;
}
- public abstract string StackTrace
+ public virtual string StackTrace
{
- get;
+ get
+ {
+ return stackTrace;
+ }
+ set
+ {
+ stackTrace = value;
+ }
}
public abstract void NotRun(string message);
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
private MethodInfo fixtureSetUp;
private MethodInfo fixtureTearDown;
private object fixture;
+ private const string FIXTURE_SETUP_FAILED = "Fixture setup failed";
- public TestSuite(string name) : base(name)
+ public TestSuite( string name ) : this( name, 0 ) { }
+
+ public TestSuite( string name, int assemblyKey )
+ : base( name, assemblyKey )
{
ShouldRun = true;
}
- public TestSuite(string parentSuiteName, string name) : base(parentSuiteName,name)
+ public void Sort()
+ {
+ this.Tests.Sort();
+
+ foreach( Test test in Tests )
+ {
+ TestSuite suite = test as TestSuite;
+ if ( suite != null )
+ suite.Sort();
+ }
+ }
+
+ public TestSuite( string parentSuiteName, string name )
+ : this( parentSuiteName, name, 0 ) { }
+
+ public TestSuite( string parentSuiteName, string name, int assemblyKey )
+ : base( parentSuiteName, name, assemblyKey )
{
ShouldRun = true;
}
test.IgnoreReason = IgnoreReason;
}
tests.Add(test);
+ if (test.IsTestCase)
+ ((TestCase) test).Suite = this;
}
protected internal virtual TestSuite CreateNewSuite(Type type)
{
- return new TestSuite(type.Namespace,type.Name);
+ int index = type.FullName.LastIndexOf( "." ) + 1;
+ string name = type.FullName.Substring( index );
+ return new TestSuite( type.Namespace, name, this.AssemblyKey);
}
public void Add(object fixture)
object[] attributes = fixture.GetType().GetCustomAttributes(ignoreMethodAttribute, false);
if(attributes.Length == 1)
{
- NUnit.Framework.IgnoreAttribute attr = (NUnit.Framework.IgnoreAttribute)attributes[0];
+ NUnit.Framework.IgnoreAttribute attr =
+ (NUnit.Framework.IgnoreAttribute)attributes[0];
testSuite.ShouldRun = false;
testSuite.IgnoreReason = attr.Reason;
}
- MethodInfo [] methods = fixture.GetType().GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.NonPublic);
+ Type fixtureAttribute = typeof(NUnit.Framework.TestFixtureAttribute);
+ attributes = fixture.GetType().GetCustomAttributes(fixtureAttribute, false);
+ if(attributes.Length == 1)
+ {
+ NUnit.Framework.TestFixtureAttribute fixtureAttr =
+ (NUnit.Framework.TestFixtureAttribute)attributes[0];
+ testSuite.Description = fixtureAttr.Description;
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // Uncomment the following code block to allow including Suites in the
+ // tree of tests. This causes a problem when the same test is added
+ // in multiple suites so we need to either fix it or prevent it.
+ //
+ // See also a line to change in TestSuiteBuilder.cs
+ ////////////////////////////////////////////////////////////////////////
+
+ // PropertyInfo [] properties = fixture.GetType().GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly);
+ // foreach(PropertyInfo property in properties)
+ // {
+ // object[] attrributes = property.GetCustomAttributes(typeof(NUnit.Framework.SuiteAttribute),false);
+ // if(attrributes.Length>0)
+ // {
+ // MethodInfo method = property.GetGetMethod(true);
+ // if(method.ReturnType!=typeof(NUnit.Core.TestSuite) || method.GetParameters().Length>0)
+ // {
+ // testSuite.ShouldRun = false;
+ // testSuite.IgnoreReason = "Invalid suite property method signature";
+ // }
+ // else
+ // {
+ // TestSuite suite = (TestSuite)property.GetValue(null, new Object[0]);
+ // foreach( Test test in suite.Tests )
+ // testSuite.Add( test );
+ // }
+ // }
+ // }
+
+ MethodInfo [] methods = fixture.GetType().GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.Static|BindingFlags.NonPublic);
foreach(MethodInfo method in methods)
{
TestCase testCase = TestCaseBuilder.Make(fixture, method);
if(testCase != null)
+ {
+ testCase.AssemblyKey = testSuite.AssemblyKey;
testSuite.Add(testCase);
+ }
}
if(testSuite.CountTestCases == 0)
}
}
+ private void CheckSuiteProperty(PropertyInfo property)
+ {
+ MethodInfo method = property.GetGetMethod(true);
+ if(method.ReturnType!=typeof(NUnit.Core.TestSuite))
+ throw new InvalidSuiteException("Invalid suite property method signature");
+ if(method.GetParameters().Length>0)
+ throw new InvalidSuiteException("Invalid suite property method signature");
+ }
+
public override ArrayList Tests
{
get { return tests; }
get { return true; }
}
+ public override bool IsTestCase
+ {
+ get { return false; }
+ }
+
+ /// <summary>
+ /// True if this is a fixture. May populate the test's
+ /// children as a side effect.
+ /// TODO: An easier way to tell this?
+ /// </summary>
+ public override bool IsFixture
+ {
+ get
+ {
+ // We have no way of constructing an empty suite unless it's a fixture
+ if ( Tests.Count == 0 ) return true;
+
+ // Any suite with children is a fixture if the children are test cases
+ ITest firstChild = (ITest)Tests[0];
+ return !firstChild.IsSuite;
+ }
+ }
+
public override int CountTestCases
{
get
}
}
+ private bool suiteRunning = false;
+
+ public bool SuiteRunning
+ {
+ get { return suiteRunning; }
+ }
+
public override TestResult Run(EventListener listener)
{
+ suiteRunning = true;
TestSuiteResult suiteResult = new TestSuiteResult(this, Name);
listener.SuiteStarted(this);
suiteResult.Executed = true;
long startTime = DateTime.Now.Ticks;
-
- try
- {
- if (this.fixtureSetUp != null)
- this.InvokeMethod(fixtureSetUp, fixture);
- RunAllTests(suiteResult,listener);
- }
- finally
- {
- if (this.fixtureTearDown != null)
- this.InvokeMethod(fixtureTearDown, fixture);
- }
+ doFixtureSetup(suiteResult);
+ RunAllTests(suiteResult,listener);
+ doFixtureTearDown(suiteResult);
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
suiteResult.Time = time;
+
if(!ShouldRun) suiteResult.NotRun(this.IgnoreReason);
listener.SuiteFinished(suiteResult);
+ suiteRunning = false;
return suiteResult;
}
+ public void InvokeFixtureTearDown()
+ {
+ if (this.fixtureTearDown != null)
+ this.InvokeMethod(fixtureTearDown, fixture);
+ }
+
+ private void doFixtureTearDown(TestSuiteResult suiteResult)
+ {
+ if (this.ShouldRun)
+ {
+ try
+ {
+ InvokeFixtureTearDown();
+ }
+ catch (Exception ex)
+ {
+ handleFixtureException(suiteResult, ex);
+ }
+ }
+ if (this.IgnoreReason == FIXTURE_SETUP_FAILED)
+ {
+ this.ShouldRun = true;
+ this.IgnoreReason = null;
+ }
+ }
+
+ private void doFixtureSetup(TestSuiteResult suiteResult)
+ {
+ try
+ {
+ InvoikeFixtureSetUp();
+ }
+ catch (Exception ex)
+ {
+ handleFixtureException(suiteResult, ex);
+ this.ShouldRun = false;
+ this.IgnoreReason = FIXTURE_SETUP_FAILED;
+ }
+ }
+
+ public void InvoikeFixtureSetUp()
+ {
+ if (this.fixtureSetUp != null)
+ this.InvokeMethod(fixtureSetUp, fixture);
+ }
+
+ private void handleFixtureException(TestSuiteResult result, Exception ex)
+ {
+ NunitException nex = ex as NunitException;
+ if (nex != null)
+ ex = nex.InnerException;
+
+ result.Executed = false;
+ result.NotRun(ex.ToString());
+ result.StackTrace = ex.StackTrace;
+ }
+
protected virtual void RunAllTests(TestSuiteResult suiteResult,EventListener listener)
{
- foreach(Test test in Tests)
+ foreach(Test test in ArrayList.Synchronized(Tests))
{
+ if (this.ShouldRun == false)
+ {
+ test.ShouldRun = false;
+ if (test.IgnoreReason == null)
+ test.IgnoreReason = FIXTURE_SETUP_FAILED;
+ }
suiteResult.AddResult(test.Run(listener));
+ if (this.ShouldRun == false)
+ {
+
+ if (test.IgnoreReason == FIXTURE_SETUP_FAILED)
+ {
+ test.ShouldRun = true;
+ test.IgnoreReason = null;
+ }
+ }
}
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
public Assembly Load(string assemblyName)
{
- Assembly assembly = AppDomain.CurrentDomain.Load(TrimPathAndExtension(assemblyName));
- return assembly;
+ // Change currentDirectory in case assembly references unmanaged dlls
+ string currentDirectory = Environment.CurrentDirectory;
+ string assemblyDirectory = Path.GetDirectoryName( assemblyName );
+ bool swap = assemblyDirectory != null && assemblyDirectory != string.Empty;
+
+ try
+ {
+ if ( swap )
+ Environment.CurrentDirectory = assemblyDirectory;
+
+ return AppDomain.CurrentDomain.Load(TrimPathAndExtension(assemblyName));
+ }
+ finally
+ {
+ if ( swap )
+ Environment.CurrentDirectory = currentDirectory;
+ }
+
+
}
- private TestSuite BuildFromNameSpace(string nameSpace)
+ private TestSuite BuildFromNameSpace( string nameSpace, int assemblyKey )
{
if( nameSpace == null || nameSpace == "" ) return rootSuite;
TestSuite suite = (TestSuite)suites[nameSpace];
if(suite!=null) return suite;
+
int index = nameSpace.LastIndexOf(".");
- if(index==-1)
+ string prefix = string.Format( "[{0}]", assemblyKey );
+ if( index == -1 )
{
- suite = new TestSuite(nameSpace);
+ suite = new TestSuite( nameSpace, assemblyKey );
rootSuite.Add(suite);
suites[nameSpace]=suite;
- return suite;
}
- string parentNameSpace=nameSpace.Substring( 0,index);
- TestSuite parent = BuildFromNameSpace(parentNameSpace);
- string suiteName = nameSpace.Substring(index+1);
- suite = new TestSuite(parentNameSpace,suiteName);
- suites[nameSpace]=suite;
- parent.Add(suite);
+ else
+ {
+ string parentNameSpace = nameSpace.Substring( 0,index );
+ TestSuite parent = BuildFromNameSpace( parentNameSpace, assemblyKey );
+ string suiteName = nameSpace.Substring( index+1 );
+ suite = new TestSuite( parentNameSpace, suiteName, assemblyKey );
+ parent.Add( suite );
+ suites[nameSpace] = suite;
+ }
+
return suite;
}
- public TestSuite Build(string assemblyName)
+ public TestSuite Build(string projectName, IList assemblies)
+ {
+ RootTestSuite rootSuite = new RootTestSuite( projectName );
+
+ int assemblyKey = 0;
+ foreach(string assembly in assemblies)
+ {
+
+ TestSuite suite = Build( assembly, assemblyKey++ );
+ rootSuite.Add( suite );
+ }
+
+ return rootSuite;
+ }
+
+ public TestSuite Build( string assemblyName )
+ {
+ return Build( assemblyName, 0 );
+ }
+
+ private TestSuite Build( string assemblyName, int assemblyKey )
{
TestSuiteBuilder builder = new TestSuiteBuilder();
- Assembly assembly = Load(assemblyName);
+ Assembly assembly = Load( assemblyName );
- builder.rootSuite = new TestSuite(assemblyName);
+ builder.rootSuite = new AssemblyTestSuite( assemblyName, assemblyKey );
int testFixtureCount = 0;
Type[] testTypes = assembly.GetExportedTypes();
foreach(Type testType in testTypes)
{
+ ////////////////////////////////////////////////////////////////////////
+ // Use the second if statement to allow including Suites in the
+ // tree of tests. This causes a problem when the same test is added
+ // in multiple suites so we need to either fix it or prevent it.
+ //
+ // See also the block of code to uncomment in TestSUite.cs
+ ////////////////////////////////////////////////////////////////////////
+
if(IsTestFixture(testType))
+ //if(IsTestFixture(testType) || IsTestSuiteProperty(testType))
{
testFixtureCount++;
string namespaces = testType.Namespace;
- TestSuite suite = builder.BuildFromNameSpace(namespaces);
+ TestSuite suite = builder.BuildFromNameSpace( namespaces, assemblyKey );
try
{
- object fixture = BuildTestFixture(testType);
+ object fixture = BuildTestFixture( testType );
suite.Add(fixture);
}
catch(InvalidTestFixtureException exception)
}
if(testFixtureCount == 0)
- throw new NoTestFixturesException(assemblyName + " has no TestFixtures");
+ {
+ //throw new NoTestFixturesException(assemblyName + " has no TestFixtures");
+ builder.rootSuite.ShouldRun = false;
+ builder.rootSuite.IgnoreReason = "Has no TestFixtures";
+ }
return builder.rootSuite;
}
- public TestSuite Build(string testName, string assemblyName)
+ public TestSuite Build(string assemblyName, string testName )
{
TestSuite suite = null;
return suite;
}
+ public TestSuite Build( IList assemblies, string testName )
+ {
+ TestSuite suite = null;
+
+ foreach(string assemblyName in assemblies)
+ {
+ Assembly assembly = Load(assemblyName);
+ if(assembly != null)
+ {
+ Type testType = assembly.GetType(testName);
+ if(testType != null)
+ {
+ if(IsTestFixture(testType))
+ {
+ suite = MakeSuiteFromTestFixtureType(testType);
+ break;
+ }
+ else if(IsTestSuiteProperty(testType))
+ {
+ suite = MakeSuiteFromProperty(testType);
+ break;
+ }
+ }
+ }
+ }
+
+ return suite;
+ }
+
private bool IsTestFixture(Type type)
{
if(type.IsAbstract) return false;
return type.IsDefined(typeof(NUnit.Framework.TestFixtureAttribute), true);
}
- public object BuildTestFixture(Type fixtureType)
+ public object BuildTestFixture( Type fixtureType )
{
ConstructorInfo ctor = fixtureType.GetConstructor(Type.EmptyTypes);
if(ctor == null) throw new InvalidTestFixtureException(fixtureType.FullName + " does not have a valid constructor");
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
private ArrayList results = new ArrayList();
private string message;
- public TestSuiteResult(Test test, string name) : base(test, name)
+ public TestSuiteResult(ITest test, string name) : base(test, name)
{
Executed = false;
}
}
}
+ public override bool AllTestsExecuted
+ {
+ get
+ {
+ if (!this.Executed)
+ return false;
+
+ foreach( TestResult testResult in results )
+ {
+ if ( !testResult.AllTestsExecuted )
+ return false;
+ }
+ return true;
+ }
+ }
+
public override void NotRun(string message)
{
this.Executed = false;
get { return message; }
}
- public override string StackTrace
- {
- get { return null; }
- }
-
-
public IList Results
{
get { return results; }
public override void Accept(ResultVisitor visitor)
{
- visitor.visit(this);
+ visitor.Visit(this);
}
}
}
-<?xml version="1.0" encoding="utf-8"?>\r
-<root>\r
- <!-- \r
- Microsoft ResX Schema \r
- \r
- Version 1.3\r
- \r
- The primary goals of this format is to allow a simple XML format \r
- that is mostly human readable. The generation and parsing of the \r
- various data types are done through the TypeConverter classes \r
- associated with the data types.\r
- \r
- Example:\r
- \r
- ... ado.net/XML headers & schema ...\r
- <resheader name="resmimetype">text/microsoft-resx</resheader>\r
- <resheader name="version">1.3</resheader>\r
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
- <data name="Name1">this is my long string</data>\r
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
- [base64 mime encoded serialized .NET Framework object]\r
- </data>\r
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
- [base64 mime encoded string representing a byte array form of the .NET Framework object]\r
- </data>\r
- \r
- There are any number of "resheader" rows that contain simple \r
- name/value pairs.\r
- \r
- Each data row contains a name, and value. The row also contains a \r
- type or mimetype. Type corresponds to a .NET class that support \r
- text/value conversion through the TypeConverter architecture. \r
- Classes that don't support this are serialized and stored with the \r
- mimetype set.\r
- \r
- The mimetype is used for serialized objects, and tells the \r
- ResXResourceReader how to depersist the object. This is currently not \r
- extensible. For a given mimetype the value must be set accordingly:\r
- \r
- Note - application/x-microsoft.net.object.binary.base64 is the format \r
- that the ResXResourceWriter will generate, however the reader can \r
- read any of the formats listed below.\r
- \r
- mimetype: application/x-microsoft.net.object.binary.base64\r
- value : The object must be serialized with \r
- : System.Serialization.Formatters.Binary.BinaryFormatter\r
- : and then encoded with base64 encoding.\r
- \r
- mimetype: application/x-microsoft.net.object.soap.base64\r
- value : The object must be serialized with \r
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
- : and then encoded with base64 encoding.\r
- mimetype: application/x-microsoft.net.object.bytearray.base64\r
- value : The object must be serialized into a byte array \r
- : using a System.ComponentModel.TypeConverter\r
- : and then encoded with base64 encoding.\r
- -->\r
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
- <xsd:element name="root" msdata:IsDataSet="true">\r
- <xsd:complexType>\r
- <xsd:choice maxOccurs="unbounded">\r
- <xsd:element name="data">\r
- <xsd:complexType>\r
- <xsd:sequence>\r
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
- </xsd:sequence>\r
- <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />\r
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
- </xsd:complexType>\r
- </xsd:element>\r
- <xsd:element name="resheader">\r
- <xsd:complexType>\r
- <xsd:sequence>\r
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
- </xsd:sequence>\r
- <xsd:attribute name="name" type="xsd:string" use="required" />\r
- </xsd:complexType>\r
- </xsd:element>\r
- </xsd:choice>\r
- </xsd:complexType>\r
- </xsd:element>\r
- </xsd:schema>\r
- <resheader name="resmimetype">\r
- <value>text/microsoft-resx</value>\r
- </resheader>\r
- <resheader name="version">\r
- <value>1.3</value>\r
- </resheader>\r
- <resheader name="reader">\r
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
- </resheader>\r
- <resheader name="writer">\r
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
- </resheader>\r
- <data name="Summary.xslt">\r
- <value><?xml version="1.0" encoding="UTF-8" ?>\r
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
-<xsl:output method='text'/>\r
-\r
-<xsl:template match="/">\r
- <xsl:apply-templates/>\r
-</xsl:template>\r
-\r
-<xsl:template match="test-results">\r
-<xsl:text>Tests run: </xsl:text>\r
-<xsl:value-of select="@total"/>\r
-<xsl:text>, Failures: </xsl:text>\r
-<xsl:value-of select="@failures"/>\r
-<xsl:text>, Not run: </xsl:text>\r
-<xsl:value-of select="@not-run"/>\r
-<xsl:text>, Time: </xsl:text>\r
-<xsl:value-of select="test-suite/@time"/>\r
-<xsl:text> seconds\r
-</xsl:text>\r
-<xsl:text>\r
-</xsl:text>\r
-\r
-<xsl:if test="//test-case[failure]"><xsl:text>Failures:\r
-</xsl:text></xsl:if>\r
-<xsl:apply-templates select="//test-case[failure]"/>\r
-<xsl:if test="//test-case[@executed='False']"><xsl:text>Tests not run:\r
-</xsl:text></xsl:if>\r
-<xsl:apply-templates select="//test-case[@executed='False']"/>\r
-<xsl:text disable-output-escaping='yes'>&#xA;</xsl:text>\r
-</xsl:template>\r
-\r
-<xsl:template match="test-case">\r
- <xsl:value-of select="position()"/><xsl:text>) </xsl:text>\r
- <xsl:value-of select="@name"/>\r
- <xsl:text> : </xsl:text>\r
- <xsl:value-of select="child::node()/message"/>\r
-<xsl:text disable-output-escaping='yes'>&#xA;</xsl:text>\r
- <xsl:if test="failure">\r
- <xsl:value-of select="failure/stack-trace"/>\r
-<xsl:text>\r
-</xsl:text>\r
- </xsl:if>\r
-</xsl:template>\r
-\r
-</xsl:stylesheet>\r
-\r
- </value>\r
- </data>\r
+<?xml version="1.0" encoding="utf-8" ?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="Summary.xslt">
+ <value><?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method='text'/>
+
+<xsl:template match="/">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="test-results">
+<xsl:text>Tests run: </xsl:text>
+<xsl:value-of select="@total"/>
+<xsl:text>, Failures: </xsl:text>
+<xsl:value-of select="@failures"/>
+<xsl:text>, Not run: </xsl:text>
+<xsl:value-of select="@not-run"/>
+<xsl:text>, Time: </xsl:text>
+<xsl:value-of select="test-suite/@time"/>
+<xsl:text> seconds
+</xsl:text>
+<xsl:text>
+</xsl:text>
+
+<xsl:if test="//test-case[failure]"><xsl:text>Failures:
+</xsl:text></xsl:if>
+<xsl:apply-templates select="//test-case[failure]"/>
+<xsl:if test="//test-case[@executed='False']"><xsl:text>Tests not run:
+</xsl:text></xsl:if>
+<xsl:apply-templates select="//test-case[@executed='False']"/>
+<xsl:text disable-output-escaping='yes'>&#xD;&#xA;</xsl:text>
+</xsl:template>
+
+<xsl:template match="test-case">
+ <xsl:value-of select="position()"/><xsl:text>) </xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text> : </xsl:text>
+ <xsl:value-of select="child::node()/message"/>
+<xsl:text disable-output-escaping='yes'>&#xD;&#xA;</xsl:text>
+ <xsl:if test="failure">
+ <xsl:value-of select="failure/stack-trace"/>
+<xsl:text>
+</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
+
+ </value>
+ </data>
</root>
\ No newline at end of file
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
public class XmlResultVisitor : ResultVisitor
{
private XmlTextWriter xmlWriter;
+ private TextWriter writer;
+ private MemoryStream memoryStream;
public XmlResultVisitor(string fileName, TestResult result)
+ {
+ xmlWriter = new XmlTextWriter( new StreamWriter(fileName, false, System.Text.Encoding.UTF8) );
+ Initialize(result);
+ }
+
+ public XmlResultVisitor( TextWriter writer, TestResult result )
+ {
+ this.memoryStream = new MemoryStream();
+ this.writer = writer;
+ this.xmlWriter = new XmlTextWriter( new StreamWriter( memoryStream, System.Text.Encoding.UTF8 ) );
+ Initialize( result );
+ }
+
+ private void Initialize(TestResult result)
{
ResultSummarizer summaryResults = new ResultSummarizer(result);
- try
- {
- xmlWriter = new XmlTextWriter (fileName, null);
- }
- catch(Exception e)
- {
- Console.Error.WriteLine(e.StackTrace);
- }
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(false);
DateTime now = DateTime.Now;
xmlWriter.WriteAttributeString("date", now.ToShortDateString());
xmlWriter.WriteAttributeString("time", now.ToShortTimeString());
-
}
- public void visit(TestCaseResult caseResult)
+ public void Visit(TestCaseResult caseResult)
{
xmlWriter.WriteStartElement("test-case");
xmlWriter.WriteAttributeString("name",caseResult.Name);
+
+ if(caseResult.Description != null)
+ xmlWriter.WriteAttributeString("description", caseResult.Description);
+
xmlWriter.WriteAttributeString("executed", caseResult.Executed.ToString());
if(caseResult.Executed)
{
xmlWriter.WriteStartElement("error");
xmlWriter.WriteStartElement("message");
- xmlWriter.WriteCData(caseResult.Message);
+ xmlWriter.WriteCData( EncodeCData( caseResult.Message ) );
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("stack-trace");
if(caseResult.StackTrace != null)
- xmlWriter.WriteCData(StackTraceFilter.Filter(caseResult.StackTrace));
+ xmlWriter.WriteCData( EncodeCData( StackTraceFilter.Filter( caseResult.StackTrace ) ) );
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
}
- public void visit(TestSuiteResult suiteResult)
+ private string EncodeCData( string text )
+ {
+ if ( text.IndexOf( "]]>" ) < 0 )
+ return text;
+
+ return text.Replace( "]]>", "]]>" );
+ }
+
+ public void Visit(TestSuiteResult suiteResult)
{
xmlWriter.WriteStartElement("test-suite");
xmlWriter.WriteAttributeString("name",suiteResult.Name);
+ if(suiteResult.Description != null)
+ xmlWriter.WriteAttributeString("description", suiteResult.Description);
+
xmlWriter.WriteAttributeString("success", suiteResult.IsSuccess.ToString());
xmlWriter.WriteAttributeString("time", suiteResult.Time.ToString());
public void Write()
{
- xmlWriter.WriteEndElement();
+ try
+ {
+ xmlWriter.WriteEndElement();
+ xmlWriter.WriteEndDocument();
+ xmlWriter.Flush();
+
+ if ( memoryStream != null && writer != null )
+ {
+ memoryStream.Position = 0;
+ using ( StreamReader rdr = new StreamReader( memoryStream ) )
+ {
+ writer.Write( rdr.ReadToEnd() );
+ }
+ }
- xmlWriter.WriteEndDocument();
- xmlWriter.Flush();
- xmlWriter.Close();
+ xmlWriter.Close();
+ }
+ finally
+ {
+ //writer.Close();
+ }
}
}
}
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
- ProductVersion = "7.0.9466"
- SchemaVersion = "1.0"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
ProjectGuid = "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"
>
<Build>
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
RootNamespace = "NUnit.Framework"
+ RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE;NUNIT_LEAKAGE_TEST"
- DocumentationFile = ""
+ DocumentationFile = "bin\Debug\nunit.framework.xml"
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE;StronglyNamedAssembly"
- DocumentationFile = ""
+ DocumentationFile = "bin\Release\nunit.framework.xml"
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "Assert.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "Assertion.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "ITest.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "LongLivingMarshalByRefObject.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "RootTestSuite.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "SetUpAttribute.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "StringTextWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "SuiteAttribute.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "TestAssembly.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "TestAttribute.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
- <File
- RelPath = "TestInfo.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
<File
RelPath = "TestResult.cs"
SubType = "Code"
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2002 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2002 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NUnit")]
-[assembly: AssemblyCopyright("Copyright (C) 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. \nCopyright (C) 2000-2002 Philip Craig.\nAll Rights Reserved.")]
+[assembly: AssemblyCopyright("Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.\r\nCopyright (C) 2000-2003 Philip Craig.\r\nAll Rights Reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("2.0.9.001")]
+[assembly: AssemblyVersion("2.1.4.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
namespace NUnit.Console
{
using System;
+ using System.Collections;
+ using System.Collections.Specialized;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.XPath;
using System.Resources;
using System.Text;
+ using System.Text.RegularExpressions;
+ using System.Diagnostics;
using NUnit.Core;
using NUnit.Util;
/// </summary>
public class ConsoleUi
{
- private NUnit.Framework.TestDomain testDomain;
- private string outputFile;
+ private NUnit.Core.TestDomain testDomain;
private XmlTextReader transformReader;
+ private bool silent;
+ private string xmlOutput;
+ [STAThread]
public static int Main(string[] args)
{
int returnCode = 0;
}
else if(parser.NoArgs)
{
- Console.Error.WriteLine("\nfatal error: no inputs specified");
+ Console.Error.WriteLine("fatal error: no inputs specified");
parser.Help();
}
else if(!parser.Validate())
{
- Console.Error.WriteLine("\nfatal error: invalid arguments");
+ Console.Error.WriteLine("fatal error: invalid arguments");
parser.Help();
returnCode = 2;
}
else
{
- ConsoleWriter outStream = new ConsoleWriter(Console.Out);
- ConsoleWriter errorStream = new ConsoleWriter(Console.Error);
- NUnit.Framework.TestDomain domain = new NUnit.Framework.TestDomain(outStream, errorStream);
+ NUnit.Core.TestDomain domain = new NUnit.Core.TestDomain();
- Test test = MakeTestFromCommandLine(domain, parser);
try
{
+ Test test = MakeTestFromCommandLine(domain, parser);
+
if(test == null)
{
- Console.Error.WriteLine("\nfatal error: invalid assembly {0}", parser.Assembly);
+ Console.Error.WriteLine("fatal error: invalid assembly {0}", parser.Parameters[0]);
returnCode = 2;
}
else
{
- Directory.SetCurrentDirectory(new FileInfo(parser.Assembly).DirectoryName);
+ Directory.SetCurrentDirectory(new FileInfo((string)parser.Parameters[0]).DirectoryName);
string xmlResult = "TestResult.xml";
if(parser.IsXml)
xmlResult = parser.xml;
-
+
XmlTextReader reader = GetTransformReader(parser);
if(reader != null)
{
- ConsoleUi consoleUi = new ConsoleUi(domain, xmlResult, reader);
+ ConsoleUi consoleUi = new ConsoleUi(domain, reader, parser.xmlConsole);
returnCode = consoleUi.Execute();
- if(parser.wait)
+
+ if (parser.xmlConsole)
+ Console.WriteLine(consoleUi.XmlOutput);
+ using (StreamWriter writer = new StreamWriter(xmlResult))
{
- Console.Out.WriteLine("Hit <enter> key to continue");
- Console.ReadLine();
+ writer.Write(consoleUi.XmlOutput);
}
}
else
returnCode = 3;
}
}
+ catch( Exception ex )
+ {
+ Console.WriteLine( "Unhandled Exception: {0}", ex.ToString() );
+ }
finally
{
domain.Unload();
+
+ if(parser.wait)
+ {
+ Console.Out.WriteLine("\nHit <enter> key to continue");
+ Console.ReadLine();
+ }
}
}
-
return returnCode;
}
FileInfo xsltInfo = new FileInfo(parser.transform);
if(!xsltInfo.Exists)
{
- Console.Error.WriteLine("\nTransform file: {0} does not exist", xsltInfo.FullName);
+ Console.Error.WriteLine("Transform file: {0} does not exist", xsltInfo.FullName);
reader = null;
}
else
Console.WriteLine(String.Format("{0} version {1}", productAttr.Product, version.ToString(3)));
Console.WriteLine(copyrightAttr.Copyright);
+ Console.WriteLine();
}
- private static Test MakeTestFromCommandLine(NUnit.Framework.TestDomain testDomain,
+ private static Test MakeTestFromCommandLine(NUnit.Core.TestDomain testDomain,
ConsoleOptions parser)
{
- Test test = null;
-
- if(!DoesFileExist(parser.Assembly)) return null;
+ if(!DoAssembliesExist(parser.Parameters)) return null;
- if(parser.IsAssembly)
- {
- test = testDomain.Load(parser.Assembly);
- if(test == null) Console.WriteLine("\nfatal error: assembly ({0}) is invalid", parser.Assembly);
- }
- else if(parser.IsFixture)
+ NUnitProject project;
+
+ if ( parser.IsTestProject )
{
- test = testDomain.Load(parser.fixture, parser.Assembly);
- if(test == null) Console.WriteLine("\nfatal error: fixture ({0}) in assembly ({1}) is invalid", parser.fixture, parser.Assembly);
+ project = NUnitProject.LoadProject( (string)parser.Parameters[0] );
+ string configName = (string) parser.config;
+ if ( configName != null )
+ project.SetActiveConfig( configName );
}
- return test;
+ else
+ project = NUnitProject.FromAssemblies( (string[])parser.Parameters.ToArray( typeof( string ) ) );
+
+ return project.LoadTest( testDomain, parser.fixture );
+ }
+
+ private static bool DoAssembliesExist(IList files)
+ {
+ bool exist = true;
+ foreach(string fileName in files)
+ exist &= DoesFileExist(fileName);
+ return exist;
}
private static bool DoesFileExist(string fileName)
return fileInfo.Exists;
}
- private static void WriteHelp(TextWriter writer)
+ public ConsoleUi(NUnit.Core.TestDomain testDomain, XmlTextReader reader, bool silent)
{
- writer.WriteLine("\n\n NUnit console options\n");
- writer.WriteLine("/assembly:<assembly name> Assembly to test");
- writer.WriteLine("/fixture:<class name> /assembly:<assembly name> Fixture or Suite to run");
- writer.WriteLine("\n\n XML formatting options");
- writer.WriteLine("/xml:<file> XML result file to generate");
- writer.WriteLine("/transform:<file> XSL transform file");
+ this.testDomain = testDomain;
+ transformReader = reader;
+ this.silent = silent;
}
- public ConsoleUi(NUnit.Framework.TestDomain testDomain, string xmlFile, XmlTextReader reader)
+ public string XmlOutput
{
- this.testDomain = testDomain;
- outputFile = xmlFile;
- transformReader = reader;
+ get { return xmlOutput; }
}
public int Execute()
{
- EventCollector collector = new EventCollector();
- TestResult result = testDomain.Run(collector);
+ EventListener collector = null;
+ if (silent)
+ collector = new NullListener();
+ else
+ collector = new EventCollector();
+ ConsoleWriter outStream = new ConsoleWriter(Console.Out);
+ ConsoleWriter errorStream = new ConsoleWriter(Console.Error);
+
+ string savedDirectory = Environment.CurrentDirectory;
+ TestResult result = testDomain.Run(collector, outStream, errorStream);
+ Directory.SetCurrentDirectory( savedDirectory );
+
+ Console.WriteLine();
- Console.WriteLine("\n");
- XmlResultVisitor resultVisitor = new XmlResultVisitor(outputFile, result);
+ StringBuilder builder = new StringBuilder();
+ XmlResultVisitor resultVisitor = new XmlResultVisitor(new StringWriter( builder ), result);
result.Accept(resultVisitor);
resultVisitor.Write();
- CreateSummaryDocument();
+
+ xmlOutput = builder.ToString();
+
+ if (!silent)
+ CreateSummaryDocument();
int resultCode = 0;
if(result.IsFailure)
private void CreateSummaryDocument()
{
- XPathDocument originalXPathDocument = new XPathDocument (outputFile);
+ XPathDocument originalXPathDocument = new XPathDocument(new StringReader(xmlOutput));
XslTransform summaryXslTransform = new XslTransform();
summaryXslTransform.Load(transformReader);
private class EventCollector : LongLivingMarshalByRefObject, EventListener
{
+ private int level;
+ private int testRunCount;
+ private int testIgnoreCount;
+ private int failureCount;
+ StringCollection messages;
+
+ private bool debugger = false;
+
+ public EventCollector()
+ {
+ debugger = Debugger.IsAttached;
+ level = 0;
+ }
+
public void TestFinished(TestCaseResult testResult)
{
if(testResult.Executed)
{
+ testRunCount++;
if(testResult.IsFailure)
{
+ failureCount++;
Console.Write("F");
+ if ( debugger )
+ messages.Add( ParseTestCaseResult( testResult ) );
}
}
else
+ {
+ testIgnoreCount++;
Console.Write("N");
+ }
}
public void TestStarted(TestCase testCase)
Console.Write(".");
}
- public void SuiteStarted(TestSuite suite) {}
- public void SuiteFinished(TestSuiteResult result) {}
- }
+ public void SuiteStarted(TestSuite suite)
+ {
+ if ( debugger && level++ == 0 )
+ {
+ messages = new StringCollection();
+ testRunCount = 0;
+ testIgnoreCount = 0;
+ failureCount = 0;
+ Debug.WriteLine( "################################ UNIT TESTS ################################" );
+ Debug.WriteLine( "Running tests in '" + suite.FullName + "'..." );
+ }
+ }
+
+ public void SuiteFinished(TestSuiteResult suiteResult)
+ {
+ if ( debugger && --level == 0 )
+ {
+ Debug.WriteLine( "############################################################################" );
+
+ if (messages.Count == 0)
+ {
+ Debug.WriteLine( "############## S U C C E S S #################" );
+ }
+ else
+ {
+ Debug.WriteLine( "############## F A I L U R E S #################" );
+
+ foreach ( string s in messages )
+ {
+ Debug.WriteLine(s);
+ }
+ }
+
+ Debug.WriteLine( "############################################################################" );
+ Debug.WriteLine( "Executed tests : " + testRunCount );
+ Debug.WriteLine( "Ignored tests : " + testIgnoreCount );
+ Debug.WriteLine( "Failed tests : " + failureCount );
+ Debug.WriteLine( "Total time : " + suiteResult.Time + " seconds" );
+ Debug.WriteLine( "############################################################################");
+ }
+ }
+ private string ParseTestCaseResult( TestCaseResult result )
+ {
+ string[] trace = result.StackTrace.Split( System.Environment.NewLine.ToCharArray() );
+
+ foreach (string s in trace)
+ {
+ if ( s.IndexOf( result.Test.FullName ) >= 0 )
+ {
+ string link = Regex.Replace( s.Trim(), @"at " + result.Test.FullName + @"\(\) in (.*):line (.*)", "$1($2)");
+
+ string message = string.Format("{1}: {0}",
+ result.Message.Replace(System.Environment.NewLine, "; "),
+ result.Test.FullName).Trim(' ', ':');
+
+ return string.Format("{0}: {1}", link, message);
+ }
+ }
+
+ return result.Message;
+ }
+ }
}
}
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
- ProductVersion = "7.0.9466"
- SchemaVersion = "1.0"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
ProjectGuid = "{9367EC89-6A38-42BA-9607-0DC288E4BC3A}"
>
<Build>
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = 'copy "$(ProjectDir)nunit-console.exe.1.1.config" "$(TargetDir)nunit-console.exe.config"'
RootNamespace = "nunit_console"
+ RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
</Build>
<Files>
<Include>
- <File
- RelPath = "app.config"
- BuildAction = "None"
- />
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "nunit-console.exe.1.0.config"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "nunit-console.exe.1.1.config"
+ BuildAction = "None"
+ />
</Include>
</Files>
</CSHARP>
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
using System.Reflection;
using System.Runtime.CompilerServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("2.0.9.001")]
+[assembly: AssemblyVersion("2.1.4.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'***********************************************************************************/
#endregion
-
using System;
using System.IO;
using System.Text;
using System.Timers;
+using System.Collections;
+using NUnit.Core;
namespace NUnit.Util
{
/// <summary>
- /// AssemblyWatcher keeps track of a single assembly to see if
- /// it has changed. It incorporates a delayed notification
+ /// AssemblyWatcher keeps track of one or more assemblies to
+ /// see if they have changed. It incorporates a delayed notification
/// and uses a standard event to notify any interested parties
/// about the change. The path to the assembly is provided as
/// an argument to the event handler so that one routine can
/// </summary>
public class AssemblyWatcher
{
- FileSystemWatcher fileWatcher;
+ FileSystemWatcher[] fileWatcher;
+ FileInfo[] fileInfo;
+
protected System.Timers.Timer timer;
- FileInfo fileInfo;
+ protected string changedAssemblyPath;
public delegate void AssemblyChangedHandler(String fullPath);
public event AssemblyChangedHandler AssemblyChangedEvent;
- public AssemblyWatcher(int delay, FileInfo file)
+ public AssemblyWatcher( int delay, string assemblyFileName )
+ : this( delay, new string[]{ assemblyFileName } ) { }
+
+ public AssemblyWatcher( int delay, IList assemblies )
{
- fileWatcher = new FileSystemWatcher();
- fileWatcher.Path = file.DirectoryName;
- fileWatcher.Filter = file.Name;
- fileWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite;
- fileWatcher.Changed+=new FileSystemEventHandler(OnChanged);
- fileWatcher.EnableRaisingEvents = false;
+ fileInfo = new FileInfo[assemblies.Count];
+ fileWatcher = new FileSystemWatcher[assemblies.Count];
+
+ for( int i = 0; i < assemblies.Count; i++ )
+ {
+ fileInfo[i] = new FileInfo( (string)assemblies[i] );
+
+ fileWatcher[i] = new FileSystemWatcher();
+ fileWatcher[i].Path = fileInfo[i].DirectoryName;
+ fileWatcher[i].Filter = fileInfo[i].Name;
+ fileWatcher[i].NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite;
+ fileWatcher[i].Changed+=new FileSystemEventHandler(OnChanged);
+ fileWatcher[i].EnableRaisingEvents = false;
+ }
- fileInfo = file;
-
timer = new System.Timers.Timer( delay );
timer.AutoReset=false;
timer.Enabled=false;
timer.Elapsed+=new ElapsedEventHandler(OnTimer);
}
- public string Name
+ public FileInfo GetFileInfo( int index )
{
- get { return fileInfo.Name; }
+ return fileInfo[index];
}
- public string DirectoryName
- {
- get { return fileInfo.DirectoryName; }
- }
-
- public string FullName
+ public void Start()
{
- get { return fileInfo.FullName; }
+ EnableWatchers( true );
}
-
- public void Start()
+ public void Stop()
{
- fileWatcher.EnableRaisingEvents=true;
+ EnableWatchers( false );
}
- public void Stop()
+ private void EnableWatchers( bool enable )
{
- fileWatcher.EnableRaisingEvents=false;
+ foreach( FileSystemWatcher watcher in fileWatcher )
+ watcher.EnableRaisingEvents = enable;
}
protected void OnTimer(Object source, ElapsedEventArgs e)
protected void OnChanged(object source, FileSystemEventArgs e)
{
+ changedAssemblyPath = e.FullPath;
if ( timer != null )
{
lock(this)
{
if(!timer.Enabled)
- {
timer.Enabled=true;
- }
timer.Start();
}
}
protected void PublishEvent()
{
if ( AssemblyChangedEvent != null )
- AssemblyChangedEvent( fileInfo.FullName );
+ AssemblyChangedEvent( changedAssemblyPath );
}
}
}
\ No newline at end of file
protected virtual void SplitOptionAndValue(ref string opt, ref object val)
{
// Look for ":" or "=" separator in the option:
- int pos = opt.IndexOf(':');
- if (pos < 1) pos = opt.IndexOf('=');
+ int pos = opt.IndexOfAny( new char[] { ':', '=' } );
if (pos < 1) return;
val = opt.Substring(pos+1);
helpText.AppendFormat("/{0,-20}{1}", field.Name+valType, att.Description);
if (att.Short != null)
helpText.AppendFormat(" (Short format: /{0}{1})", att.Short, valType);
- helpText.Append('\n');
+ helpText.Append( Environment.NewLine );
}
}
}
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
namespace NUnit.Util
{
using System;
[Option(Description = "Fixture to test")]
public string fixture;
- [Option(Description = "Name of Xml output file")]
+ [Option(Description = "Name of XML output file")]
public string xml;
[Option(Description = "Name of transform file")]
[Option(Description = "Require input to close console window")]
public bool wait = false;
+ [Option(Description = "Display XML to the console")]
+ public bool xmlConsole;
+
+ [Option(Description = "Project configuration to load")]
+ public string config;
+
private bool isInvalid = false;
public ConsoleOptions(String[] args) : base(args)
if(IsFixture) return true;
- if(ParameterCount == 1) return true;
+ if(ParameterCount >= 1) return true;
return false;
}
- public string Assembly
+ public bool IsAssembly
{
get
{
- return (string)Parameters[0];
+ return ParameterCount >= 1 && !IsFixture;
}
}
-
- public bool IsAssembly
+ public bool IsTestProject
{
- get
+ get
{
- return ParameterCount == 1 && !IsFixture;
+ return ParameterCount == 1 && NUnitProject.CanLoadAsProject( (string)Parameters[0] );
}
}
{
get
{
- return ParameterCount == 1 &&
+ return ParameterCount >= 1 &&
((fixture != null) && (fixture.Length > 0));
}
}
return (transform != null) && (transform.Length != 0);
}
}
+
+ public override void Help()
+ {
+ Console.WriteLine();
+ Console.WriteLine( "NUNIT-CONSOLE [inputfiles] [options]" );
+ Console.WriteLine();
+ Console.WriteLine( "Runs a set of NUnit tests from the console." );
+ Console.WriteLine();
+ Console.WriteLine( "You may specify one or more assemblies or a single" );
+ Console.WriteLine( "project file of type .nunit." );
+ Console.WriteLine();
+ Console.WriteLine( "Options:" );
+ base.Help();
+ Console.WriteLine();
+ }
}
-}
\ No newline at end of file
+}
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
namespace NUnit.Util
{
using System;
[Option(Short="?", Description = "Display help")]
public bool help = false;
+ [Option(Description = "Project configuration to load")]
+ public string config;
+
+ [Option(Description = "Suppress loading of last project")]
+ public bool noload;
+
public GuiOptions(String[] args) : base(args)
{}
public bool Validate()
{
- return (NoArgs || ParameterCount == 1) && !isInvalid;
+ return (NoArgs || ParameterCount <= 1) && !isInvalid;
}
}
}
\ No newline at end of file
include ../../build/rules.make
LIBRARY = NUnit.Util.dll
+LOCAL_MCS_FLAGS= -r:NUnit.Framework.dll -r:System.Xml.dll
NO_TEST = yo
EXTRA_DISTFILES = nunit.util.dll.csproj
+./AssemblyList.cs
+./AssemblyListItem.cs
./CommandLineOptions.cs
./ConsoleOptions.cs
+./NUnitProject.cs
+./ProjectConfig.cs
+./ProjectConfigCollection.cs
+./ProjectFormatException.cs
+./ProjectPath.cs
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
namespace NUnit.Util
{
using System;
+ using System.IO;
+ using System.Text;
+ using System.Windows.Forms;
using Microsoft.Win32;
/// <summary>
/// </summary>
public class NUnitRegistry
{
- private static readonly string KEY = "Software\\Nascent Software\\Nunit\\";
+ private static readonly string KEY =
+ @"Software\Nascent Software\Nunit\";
private static bool testMode = false;
- private static string testKey = "Software\\Nascent Software\\Nunit-Test";
+ private static string testKey =
+ @"Software\Nascent Software\Nunit-Test";
+
/// <summary>
/// Prevent construction of object
public static void ClearTestKeys()
{
ClearSubKey( Registry.CurrentUser, testKey );
- ClearSubKey( Registry.LocalMachine, testKey );
+ ClearSubKey( Registry.LocalMachine, testKey );
}
/// <summary>
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
+/************************************************************************************
+'
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
+'
+' This software is provided 'as-is', without any express or implied warranty. In no
+' event will the authors be held liable for any damages arising from the use of this
+' software.
+'
+' Permission is granted to anyone to use this software for any purpose, including
+' commercial applications, and to alter it and redistribute it freely, subject to the
+' following restrictions:
+'
+' 1. The origin of this software must not be misrepresented; you must not claim that
+' you wrote the original software. If you use this software in a product, an
+' acknowledgment (see the following) in the product documentation is required.
+'
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
+'
+' 2. Altered source versions must be plainly marked as such, and must not be
+' misrepresented as being the original software.
+'
+' 3. This notice may not be removed or altered from any source distribution.
+'
+'***********************************************************************************/
+#endregion
+
using System;
using System.Diagnostics;
using NUnit.Core;
/// </summary>
public enum TestAction
{
+ // Project Loading Events
+ ProjectLoading,
+ ProjectLoaded,
+ ProjectLoadFailed,
+ ProjectUnloading,
+ ProjectUnloaded,
+ ProjectUnloadFailed,
+ // Test Loading Events
+ TestLoading,
+ TestLoaded,
+ TestLoadFailed,
+ TestReloading,
+ TestReloaded,
+ TestReloadFailed,
+ TestUnloading,
+ TestUnloaded,
+ TestUnloadFailed,
+ // Test Running Events
RunStarting,
RunFinished,
SuiteStarting,
/// </summary>
public class TestEventArgs : EventArgs
{
+ #region Instance Variables
+
+ // The action represented by the event
private TestAction action;
+
+ // The file name for the test
+ private string testFileName;
+
+ // The top node of a loaded test suite
private UITestNode test;
+
+ // The result of a test
private TestResult result;
+
+ // The exception causing a failure
private Exception exception;
- /// <summary>
- /// Helper to distinguish XxxxStarting from XxxxFinished actions
- /// </summary>
- /// <param name="action"></param>
- /// <returns></returns>
- private static bool IsStartAction( TestAction action )
+ #endregion
+
+ #region Constructors
+
+ public TestEventArgs( TestAction action,
+ string testFileName, UITestNode test )
{
- return action == TestAction.RunStarting ||
- action == TestAction.SuiteStarting ||
- action == TestAction.TestStarting;
+ this.action = action;
+ this.testFileName = testFileName;
+ this.test = test;
+ }
+
+ public TestEventArgs( TestAction action, string testFileName )
+ {
+ this.action = action;
+ this.testFileName = testFileName;
+ }
+
+ public TestEventArgs( TestAction action,
+ string testFileName, Exception exception )
+ {
+ this.action = action;
+ this.testFileName = testFileName;
+ this.exception = exception;
}
- /// <summary>
- /// Construct using action and test node
- /// Used only for XxxxStarting events
- /// </summary>
public TestEventArgs( TestAction action, UITestNode test )
{
this.action = action;
this.test = test;
- this.result = null;
- this.exception = null;
-
- Debug.Assert( IsStartAction( action ), "Invalid TestAction in Constructor" );
}
- /// <summary>
- /// Construct using action and test result
- /// Used only for XxxxFinished events
- /// </summary>
public TestEventArgs( TestAction action, TestResult result )
{
this.action = action;
- this.test = null;
this.result = result;
- this.exception = null;
-
- Debug.Assert( !IsStartAction( action ), "Invalid TestAction in Constructor" );
}
- /// <summary>
- /// Construct using action and exception
- /// Used only for RunFinished event
- /// </summary>
public TestEventArgs( TestAction action, Exception exception )
{
this.action = action;
- this.test = null;
- this.result = null;
this.exception = exception;
-
- Debug.Assert( action == TestAction.RunFinished, "Invalid TestAction in Constructor" );
}
- /// <summary>
- /// The action that triggered the event
- /// </summary>
+ #endregion
+
+ #region Properties
+
public TestAction Action
{
get { return action; }
}
- /// <summary>
- /// Test associated with a starting event
- /// </summary>
+ public string TestFileName
+ {
+ get { return testFileName; }
+ }
+
+ public bool IsProjectFile
+ {
+ get { return NUnitProject.IsProjectFile( testFileName ); }
+ }
+
public UITestNode Test
{
get { return test; }
}
- /// <summary>
- /// Result associated with a finished event
- /// </summary>
public TestResult Result
{
get { return result; }
}
- /// <summary>
- /// Exception associated with a RunFinished event
- /// when caused by a system error or user cancelation
- /// </summary>
public Exception Exception
{
get { return exception; }
}
+
+ #endregion
}
}
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
-#region Copyright (c) 2002, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Philip A. Craig
+#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
-' Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' Copyright © 2000-2002 Philip A. Craig
+' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' Copyright 2000-2002 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
-' Portions Copyright © 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
-' or Copyright © 2000-2002 Philip A. Craig
+' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
+' or Copyright 2000-2002 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
/// in the UI, avoiding the remoting issues associated
/// with holding an actual Test object.
/// </summary>
- public class UITestNode : TestInfo
+ public class UITestNode : ITest
{
#region Instance Variables
/// </summary>
private string testName;
+ /// <summary>
+ /// Used to distinguish tests in multiple assemblies;
+ /// </summary>
+ private int assemblyKey;
+
/// <summary>
/// True if the test should be run
/// </summary>
/// object was constructed. Used for deferred
/// population of the object.
/// </summary>
- private TestInfo testSuite;
+ private ITest testSuite;
+
+ /// <summary>
+ /// The test description
+ /// </summary>
+ private string description;
#endregion
#region Construction and Conversion
+ public UITestNode( string suiteName ) : this( suiteName, 0 ) { }
+
+ public UITestNode( string suiteName, int assemblyKey )
+ {
+ this.fullName = this.testName = suiteName;
+ this.assemblyKey = assemblyKey;
+ this.shouldRun = true;
+ this.isSuite = true;
+ this.testCaseCount = 0;
+ this.tests = new ArrayList();
+ }
+
+ public UITestNode( string pathName, string testName )
+ : this( pathName, testName, 0 ) { }
+
+ public UITestNode( string pathName, string testName, int assemblyKey )
+ {
+ this.fullName = pathName + "." + testName;
+ this.testName = testName;
+ this.assemblyKey = assemblyKey;
+ this.shouldRun = true;
+ this.isSuite = false;
+ this.testCaseCount = 1;
+ }
+
/// <summary>
/// Construct from a TestInfo interface, which might be
/// a Test or another UITestNode. Optionally, populate
/// </summary>
/// <param name="test">TestInfo interface from which a UITestNode is to be constructed</param>
/// <param name="populate">True if child array is to be populated</param>
- public UITestNode ( TestInfo test, bool populate )
+ public UITestNode ( ITest test, bool populate )
{
fullName = test.FullName;
testName = test.Name;
+ assemblyKey = test.AssemblyKey;
shouldRun = test.ShouldRun;
ignoreReason = test.IgnoreReason;
+ description = test.Description;
if ( test.IsSuite )
{
/// Default construction uses lazy population approach
/// </summary>
/// <param name="test"></param>
- public UITestNode ( TestInfo test ) : this( test, false ) { }
+ public UITestNode ( ITest test ) : this( test, false ) { }
/// <summary>
/// Populate the arraylist of child Tests recursively.
#region Properties
+ /// <summary>
+ /// The test description
+ /// </summary>
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+
/// <summary>
/// The reason for ignoring a test
/// </summary>
get { return testName; }
}
+ /// <summary>
+ /// Identifier for assembly containing this test
+ /// </summary>
+ public int AssemblyKey
+ {
+ get { return assemblyKey; }
+ set { assemblyKey = value; }
+ }
+
+ public string UniqueName
+ {
+ get{ return string.Format( "[{0}]{1}", assemblyKey, fullName ); }
+ }
+
/// <summary>
/// If the name is a path, this just returns the file part
/// </summary>
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
- ProductVersion = "7.0.9466"
- SchemaVersion = "1.0"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
ProjectGuid = "{61CE9CE5-943E-44D4-A381-814DC1406767}"
>
<Build>
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
RootNamespace = "NUnit.Util"
+ RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "AssemblyList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "AssemblyListItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "AssemblyWatcher.cs"
SubType = "Code"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "ITestEvents.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ITestLoader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "NUnitGuiSettings.cs"
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "NUnitProject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
<File
RelPath = "NUnitRegistry.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "RecentAssemblySettings.cs"
+ RelPath = "ProjectConfig.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ProjectConfigCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ProjectFormatException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ProjectPath.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "RecentFileSettings.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "RecentProjectSettings.cs"
SubType = "Code"
BuildAction = "Compile"
/>
BuildAction = "Compile"
/>
<File
- RelPath = "TestLoadEventArgs.cs"
+ RelPath = "TestEventDispatcher.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "TestLoader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "TestResultItem.cs"
SubType = "Code"
BuildAction = "Compile"
/>
SubType = "Code"
BuildAction = "Compile"
/>
+ <File
+ RelPath = "VSProject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "VSProjectConfig.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "VSProjectConfigCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
</Include>
</Files>
</CSHARP>