[Csmail-patches] CVS: csmail/nunit/src/NUnitConsole AssemblyInfo.cs,NONE,1.1 NUnitConsole.csproj,NON
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-07-24 10:50:21
|
Update of /cvsroot/csmail/csmail/nunit/src/NUnitConsole In directory usw-pr-cvs1:/tmp/cvs-serv27574/nunit/src/NUnitConsole Added Files: AssemblyInfo.cs NUnitConsole.csproj NUnitConsole.xml NUnitConsoleMain.cs TestRunner.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * NUnit -- Added the sourcecode. I hope there's no problem with license. --- NEW FILE --- using System; using System.Reflection; using System.Runtime.CompilerServices; // Mark the framework assembly as CLS compliant [assembly:CLSCompliant(true)] // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly:AssemblyTitle("NUnit Testing Framework")] [assembly:AssemblyDescription("A unit testing framework for the .Net platform, ported from junit by Kent Beck and Erich Gamma.")] [assembly:AssemblyConfiguration("")] [assembly:AssemblyCompany("")] [assembly:AssemblyProduct("NUnit")] [assembly:AssemblyCopyright("")] [assembly:AssemblyTrademark("")] [assembly:AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Revision // Build Number // // You can specify all the value or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly:AssemblyVersion("1.11.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified - the assembly cannot be signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. // (*) If the key file and a key name attributes are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP - that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the file is installed into the CSP and used. // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile(@"..\..\..\..\NUnit.key")] //[assembly: AssemblyKeyName("")] --- NEW FILE --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.0.9254" SchemaVersion = "1.0" > <Build> <Settings ApplicationIcon = "Logo.ico" AssemblyKeyContainerName = "" AssemblyName = "NUnitConsole" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Flow" DefaultTargetSchema = "IE32Nav30" DelaySign = "false" NoStandardLibraries = "false" OutputType = "Exe" RootNamespace = "NUnitConsole" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "0" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "NUnitConsole.xml" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "0" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "NUnitCore" Project = "{434945C6-B4F0-416B-AC43-2631EA091AAA}" Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" Private = "True" /> <Reference Name = "System" AssemblyName = "System" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NUnitConsoleMain.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TestRunner.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE --- <?xml version="1.0"?> <doc> <assembly> <name>NUnitConsole</name> </assembly> <members> <member name="T:NUnit.Top"> <summary> </summary> </member> <member name="M:NUnit.Top.Main(System.String[])"> <summary> </summary> <param name="args"></param> </member> <member name="T:NUnit.TextUI.TestRunner"> <summary>A command line based tool to run tests.</summary><remarks> <code> C:\NUnitConsole.exe /t [/wait] TestCaseClass </code> TestRunner expects the name of a TestCase class as argument. If this class defines a static <c>Suite</c> property it will be invoked and the returned test is run. Otherwise all the methods starting with "Test" having no arguments are run. When the wait command line argument is given TestRunner waits until the users types RETURN. TestRunner prints a trace as the tests are executed followed by a summary at the end.</remarks> </member> <member name="M:NUnit.TextUI.TestRunner.#ctor"> <summary> Constructs a TestRunner. </summary> </member> <member name="M:NUnit.TextUI.TestRunner.#ctor(System.IO.TextWriter)"> <summary> Constructs a TestRunner using the given stream for all the output </summary> </member> <member name="M:NUnit.TextUI.TestRunner.AddError(NUnit.Framework.ITest,System.Exception)"> <summary> </summary> <param name="test"></param> <param name="t"></param> </member> <member name="M:NUnit.TextUI.TestRunner.AddFailure(NUnit.Framework.ITest,NUnit.Framework.AssertionFailedError)"> <summary> </summary> <param name="test"></param> <param name="t"></param> </member> <member name="M:NUnit.TextUI.TestRunner.CreateTestResult"> <summary>Creates the TestResult to be used for the test run.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.DoRun(NUnit.Framework.ITest,System.Boolean)"> <summary> </summary> <param name="suite"></param> <param name="wait"></param> <returns></returns> </member> <member name="M:NUnit.TextUI.TestRunner.EndTest(NUnit.Framework.ITest)"> <summary> </summary> <param name="test"></param> </member> <member name="M:NUnit.TextUI.TestRunner.GetLoader"> <summary> </summary> <returns></returns> </member> <member name="M:NUnit.TextUI.TestRunner.Print(NUnit.Framework.TestResult)"> <summary> </summary> <param name="result"></param> </member> <member name="M:NUnit.TextUI.TestRunner.PrintErrors(NUnit.Framework.TestResult)"> <summary>Prints the errors to the standard output.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.PrintFailures(NUnit.Framework.TestResult)"> <summary>Prints failures to the standard output.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.PrintHeader(NUnit.Framework.TestResult)"> <summary>Prints the header of the report.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.Run(System.Type)"> <summary>Runs a Suite extracted from a TestCase subclass.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.Run(NUnit.Framework.ITest)"> <summary> </summary> <param name="suite"></param> </member> <member name="M:NUnit.TextUI.TestRunner.RunAndWait(NUnit.Framework.ITest)"> <summary>Runs a single test and waits until the user types RETURN.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.RunFailed(System.String)"> <summary> </summary> <param name="message"></param> </member> <member name="M:NUnit.TextUI.TestRunner.Start(System.String[])"> <summary>Starts a test run. Analyzes the command line arguments and runs the given test suite.</summary> </member> <member name="M:NUnit.TextUI.TestRunner.StartTest(NUnit.Framework.ITest)"> <summary> </summary> <param name="test"></param> </member> <member name="P:NUnit.TextUI.TestRunner.Writer"> <summary> </summary> </member> <member name="M:System.Collections.Hashtable.Synchronized(System.Collections.Hashtable)"> <summary> Returns a synchronized (thread-safe) wrapper for the Hashtable. </summary> </member> <member name="M:System.Collections.Hashtable.GetHash(System.Object)"> <summary>Returns the hash code for the specified key.</summary> </member> <member name="M:System.Collections.Hashtable.KeyEquals(System.Object,System.Object)"> <summary> Compares a specific Object with a specific key in the Hashtable. </summary> </member> </members> </doc> --- NEW FILE --- namespace NUnit { using System; using System.Collections; using NUnit.Framework; using NUnit.Runner; using NUnit.TextUI; /// <summary> /// /// </summary> public class Top { /// <summary> /// /// </summary> /// <param name="args"></param> public static void Main(string[] args) { TestRunner aTestRunner = new NUnit.TextUI.TestRunner(); try { TestResult r = aTestRunner.Start(args); if (!r.WasSuccessful) Environment.Exit(1); Environment.Exit(0); } catch(Exception e) { Console.Error.WriteLine(e.Message); Environment.Exit(2); } } } } --- NEW FILE --- namespace NUnit.TextUI { using System; using System.IO; using System.Reflection; using NUnit.Framework; using NUnit.Runner; /// <summary>A command line based tool to run tests.</summary><remarks> /// <code> /// C:\NUnitConsole.exe /t [/wait] TestCaseClass /// </code> /// TestRunner expects the name of a TestCase class as argument. /// If this class defines a static <c>Suite</c> property it /// will be invoked and the returned test is run. Otherwise all /// the methods starting with "Test" having no arguments are run. /// /// When the wait command line argument is given TestRunner /// waits until the users types RETURN. /// /// TestRunner prints a trace as the tests are executed followed by a /// summary at the end.</remarks> public class TestRunner : BaseTestRunner { int fColumn = 0; TextWriter fWriter = Console.Out; /// <summary> /// Constructs a TestRunner. /// </summary> public TestRunner() {} /// <summary> /// Constructs a TestRunner using the given stream for all the output /// </summary> public TestRunner(TextWriter writer) : this() { if (writer != null) { fWriter= writer; } else { throw new ArgumentNullException("writer"); } } /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="t"></param> public override void AddError(ITest test, Exception t) { lock(this) this.Writer.Write("E"); } /// <summary> /// /// </summary> /// <param name="test"></param> /// <param name="t"></param> public override void AddFailure(ITest test, AssertionFailedError t) { lock (this) this.Writer.Write("F"); } /// <summary>Creates the TestResult to be used for the test run.</summary> protected TestResult CreateTestResult() { return new TestResult(); } /// <summary> /// /// </summary> /// <param name="suite"></param> /// <param name="wait"></param> /// <returns></returns> protected TestResult DoRun(ITest suite, bool wait) { TestResult result= CreateTestResult(); result.AddListener(this); long startTime= System.DateTime.Now.Ticks; suite.Run(result); long endTime= System.DateTime.Now.Ticks; long runTime= (endTime-startTime) / 10000; Writer.WriteLine(); Writer.WriteLine("Time: "+ElapsedTimeAsString(runTime)); Print(result); Writer.WriteLine(); if (wait) { Writer.WriteLine("<RETURN> to continue"); try { Console.ReadLine(); } catch(Exception) { } } return result; } /// <summary> /// /// </summary> /// <param name="test"></param> public override void EndTest(ITest test) { } /// <summary> /// /// </summary> /// <returns></returns> public override ITestLoader GetLoader() { return new StandardLoader(); } /// <summary> /// /// </summary> /// <param name="result"></param> public void Print(TestResult result) { lock(this) { PrintErrors(result); PrintFailures(result); PrintHeader(result); } } /// <summary>Prints the errors to the standard output.</summary> public void PrintErrors(TestResult result) { if (result.ErrorCount != 0) { if (result.ErrorCount == 1) Writer.WriteLine("There was "+result.ErrorCount+" error:"); else Writer.WriteLine("There were "+result.ErrorCount+" errors:"); int i= 1; foreach (TestFailure failure in result.Errors) { Writer.WriteLine(i++ + ") "+failure+"("+failure.ThrownException.GetType().ToString()+")"); Writer.Write(GetFilteredTrace(failure.ThrownException)); } } } /// <summary>Prints failures to the standard output.</summary> public void PrintFailures(TestResult result) { if (result.FailureCount != 0) { if (result.FailureCount == 1) Writer.WriteLine("There was " + result.FailureCount + " failure:"); else Writer.WriteLine("There were " + result.FailureCount + " failures:"); int i = 1; foreach (TestFailure failure in result.Failures) { Writer.Write(i++ + ") " + failure.FailedTest); Exception t= failure.ThrownException; if (t.Message != "") Writer.WriteLine(" \"" + Truncate(t.Message) + "\""); else { Writer.WriteLine(); Writer.Write(GetFilteredTrace(failure.ThrownException)); } } } } /// <summary>Prints the header of the report.</summary> public void PrintHeader(TestResult result) { if (result.WasSuccessful) { Writer.WriteLine(); Writer.Write("OK"); Writer.WriteLine (" (" + result.RunCount + " tests)"); } else { Writer.WriteLine(); Writer.WriteLine("FAILURES!!!"); Writer.WriteLine("Tests Run: "+result.RunCount+ ", Failures: "+result.FailureCount+ ", Errors: "+result.ErrorCount); } } /// <summary>Runs a Suite extracted from a TestCase subclass.</summary> static public void Run(Type testClass) { Run(new TestSuite(testClass)); } /// <summary> /// /// </summary> /// <param name="suite"></param> static public void Run(ITest suite) { TestRunner aTestRunner= new TestRunner(); aTestRunner.DoRun(suite, false); } /// <summary>Runs a single test and waits until the user /// types RETURN.</summary> static public void RunAndWait(ITest suite) { TestRunner aTestRunner= new TestRunner(); aTestRunner.DoRun(suite, true); } /// <summary> /// /// </summary> /// <param name="message"></param> protected override void RunFailed(string message) { Console.Error.WriteLine(message); Environment.ExitCode = 1; throw new ApplicationException(message); } /// <summary>Starts a test run. Analyzes the command line arguments /// and runs the given test suite.</summary> public TestResult Start(string[] args) { bool wait = false; string testCase = ProcessArguments(args, ref wait); if (testCase.Equals("")) throw new ApplicationException("Usage: NUnitConsole.exe [/wait] testCaseName, where\n" + "name is the name of the TestCase class"); try { ITest suite = GetTest(testCase); return DoRun(suite, wait); } catch (Exception e) { throw new ApplicationException("Could not create and run test suite.", e); } } /// <summary> /// /// </summary> /// <param name="test"></param> public override void StartTest(ITest test) { lock (this) { Writer.Write("."); if (fColumn++ >= 40) { Writer.WriteLine(); fColumn = 0; } } } /// <summary> /// /// </summary> protected TextWriter Writer { get { return fWriter; } } } } |