1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
4 ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright 2000-2002 Philip A. Craig
7 ' This software is provided 'as-is', without any express or implied warranty. In no
8 ' event will the authors be held liable for any damages arising from the use of this
11 ' Permission is granted to anyone to use this software for any purpose, including
12 ' commercial applications, and to alter it and redistribute it freely, subject to the
13 ' following restrictions:
15 ' 1. The origin of this software must not be misrepresented; you must not claim that
16 ' you wrote the original software. If you use this software in a product, an
17 ' acknowledgment (see the following) in the product documentation is required.
19 ' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright 2000-2002 Philip A. Craig
22 ' 2. Altered source versions must be plainly marked as such, and must not be
23 ' misrepresented as being the original software.
25 ' 3. This notice may not be removed or altered from any source distribution.
27 '***********************************************************************************/
35 public class ConsoleOptions : CommandLineOptions
37 [Option(Description = "Fixture to test")]
38 public string fixture;
40 [Option(Description = "Project configuration to load")]
43 [Option(Description = "Name of XML output file")]
46 [Option(Description = "Name of transform file")]
47 public string transform;
49 [Option(Description = "Display XML to the console")]
50 public bool xmlConsole;
52 [Option(Short="out", Description = "File to receive test output")]
55 [Option(Description = "File to receive test error output")]
58 [Option(Description = "Label each test in stdOut")]
59 public bool labels = false;
61 [Option(Description = "List of categories to include")]
62 public string include;
64 [Option(Description = "List of categories to exclude")]
65 public string exclude;
67 // [Option(Description = "Run in a separate process")]
68 // public bool process;
70 // [Option(Description = "Run in a separate AppDomain")]
71 // public bool domain;
73 // [Option(Description = "Disable shadow copy when running in separate domain")]
74 [Option(Description = "Disable shadow copy")]
77 [Option (Description = "Run tests on a separate thread")]
80 [Option(Description = "Wait for input before closing console window")]
81 public bool wait = false;
83 [Option(Description = "Do not display the logo")]
84 public bool nologo = false;
86 [Option(Short="?", Description = "Display help")]
87 public bool help = false;
89 private bool isInvalid = false;
91 public ConsoleOptions(String[] args) : base(args)
94 protected override void InvalidOption(string name)
99 public bool Validate()
101 if(isInvalid) return false;
103 if(HasInclude && HasExclude) return false;
105 if(NoArgs) return true;
107 if(IsFixture) return true;
109 if(ParameterCount >= 1) return true;
114 public bool IsAssembly
118 return ParameterCount >= 1 && !IsFixture;
122 public bool IsTestProject
126 return ParameterCount == 1 && NUnitProject.CanLoadAsProject( (string)Parameters[0] );
130 public bool IsFixture
134 return ParameterCount >= 1 &&
135 ((fixture != null) && (fixture.Length > 0));
143 return (xml != null) && (xml.Length != 0);
151 return (output != null) && (output.Length != 0);
159 return (err != null) && (err.Length != 0);
163 public bool IsTransform
167 return (transform != null) && (transform.Length != 0);
171 public bool HasInclude
175 return include != null && include.Length != 0;
179 public bool HasExclude
183 return exclude != null && exclude.Length != 0;
187 public string[] IncludedCategories
192 return include.Split( new char[] {';', ','});
198 public string[] ExcludedCategories
203 return exclude.Split( new char[] {';', ','});
209 public override void Help()
212 Console.WriteLine( "NUNIT-CONSOLE [inputfiles] [options]" );
214 Console.WriteLine( "Runs a set of NUnit tests from the console." );
216 Console.WriteLine( "You may specify one or more assemblies or a single" );
217 Console.WriteLine( "project file of type .nunit." );
219 Console.WriteLine( "Options:" );
222 Console.WriteLine( "Options that take values may use an equal sign, a colon" );
223 Console.WriteLine( "or a space to separate the option from its value." );