public void CanRecognizeBooleanOptions(string propertyName, string pattern) { string[] prototypes = pattern.Split('|'); PropertyInfo property = GetPropertyInfo(propertyName); Assert.AreEqual(typeof(bool), property.PropertyType, "Property '{0}' is wrong type", propertyName); foreach (string option in prototypes) { ConsoleOptions options; if (option.Length == 1) { options = new ConsoleOptions("-" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option); options = new ConsoleOptions("-" + option + "+"); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "+"); options = new ConsoleOptions("-" + option + "-"); Assert.AreEqual(false, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "-"); } else { options = new ConsoleOptions("--" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize --" + option); } options = new ConsoleOptions("/" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize /" + option); } }
public void WhenTimeoutIsSpecified_RunSettingsIncludeIt() { var options = new ConsoleOptions("test.dll", "--timeout=50"); var settings = TextRunner.MakeRunSettings(options); Assert.That(settings.ContainsKey("DefaultTimeout")); Assert.AreEqual(50, settings["DefaultTimeout"]); }
public void WhenWorkDirectoryIsSpecified_RunSettingsIncludeIt() { var options = new ConsoleOptions("test.dll", "--work=results"); var settings = TextRunner.MakeRunSettings(options); Assert.That(settings.ContainsKey("WorkDirectory")); Assert.AreEqual(Path.GetFullPath("results"), settings["WorkDirectory"]); }
public void WhenSeedIsSpecified_RunSettingsIncludeIt() { var options = new ConsoleOptions("test.dll", "--seed=1234"); var settings = TextRunner.MakeRunSettings(options); Assert.That(settings.ContainsKey("RandomSeed")); Assert.AreEqual(1234, settings["RandomSeed"]); }
public void SingleAssembly() { var options = new ConsoleOptions("test.dll"); var package = ConsoleRunner.MakeTestPackage(options); Assert.AreEqual(1, package.SubPackages.Count); Assert.AreEqual(Path.GetFullPath("test.dll"), package.SubPackages[0].FullName); }
public void WhenOptionIsSpecified_PackageIncludesSetting(string option, string key, object val) { var options = new ConsoleOptions("test.dll", option); var package = ConsoleRunner.MakeTestPackage(options); Assert.That(package.Settings.ContainsKey(key), "Setting not included for {0}", option); Assert.AreEqual(val, package.Settings[key], "NumberOfTestWorkers not set correctly for {0}", option); }
public void WhenDebugging_NumberOfTestWorkersDefaultsToZero() { var options = new ConsoleOptions("test.dll", "--debug"); var package = ConsoleRunner.MakeTestPackage(options); Assert.That(package.Settings["DebugTests"], Is.EqualTo(true)); Assert.That(package.Settings["NumberOfTestWorkers"], Is.EqualTo(0)); }
public void MultipleAssemblies() { var names = new [] { "test1.dll", "test2.dll", "test3.dll" }; var options = new ConsoleOptions(names); var package = ConsoleRunner.MakeTestPackage(options); Assert.AreEqual(3, package.SubPackages.Count); Assert.AreEqual(Path.GetFullPath("test1.dll"), package.SubPackages[0].FullName); Assert.AreEqual(Path.GetFullPath("test2.dll"), package.SubPackages[1].FullName); Assert.AreEqual(Path.GetFullPath("test3.dll"), package.SubPackages[2].FullName); }
public void InvalidOption() { ConsoleOptions options = new ConsoleOptions("-assembly:nunit.tests.dll"); Assert.False(options.Validate()); Assert.AreEqual(1, options.ErrorMessages.Count); Assert.AreEqual("Invalid argument: -assembly:nunit.tests.dll", options.ErrorMessages[0]); }
public void TimeoutIsMinusOneIfNoOptionIsProvided() { ConsoleOptions options = new ConsoleOptions("tests.dll"); Assert.True(options.Validate()); Assert.AreEqual(-1, options.DefaultTimeout); }
public void InvalidCommandLineParms() { ConsoleOptions options = new ConsoleOptions("-garbage:TestFixture", "-assembly:Tests.dll"); Assert.False(options.Validate()); Assert.AreEqual(2, options.ErrorMessages.Count); Assert.AreEqual("Invalid argument: -garbage:TestFixture", options.ErrorMessages[0]); Assert.AreEqual("Invalid argument: -assembly:Tests.dll", options.ErrorMessages[1]); }
public void ExploreOptionWithFilePathUsingEqualSign() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore=C:/nunit/tests/bin/Debug/console-test.xml"); Assert.True(options.Validate()); Assert.True(options.Explore); Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set"); Assert.AreEqual("tests.dll", options.InputFiles[0]); Assert.AreEqual("C:/nunit/tests/bin/Debug/console-test.xml", options.ExploreOutputSpecifications[0].OutputPath); }
public void ShouldSetTeamCityFlagAccordingToArgsAndDefauls(bool hasTeamcityInCmd, bool? defaultTeamcity, bool expectedTeamCity) { // Given List<string> args = new List<string> { "tests.dll" }; if (hasTeamcityInCmd) { args.Add("--teamcity"); } ConsoleOptions options; if (defaultTeamcity.HasValue) { options = new ConsoleOptions(new DefaultOptionsProviderStub(defaultTeamcity.Value), args.ToArray()); } else { options = new ConsoleOptions(args.ToArray()); } // When var actualTeamCity = options.TeamCity; // Then Assert.AreEqual(actualTeamCity, expectedTeamCity); }
public void AssemblyName() { ConsoleOptions options = new ConsoleOptions("nunit.tests.dll"); Assert.True(options.Validate()); Assert.AreEqual(1, options.InputFiles.Count); Assert.AreEqual("nunit.tests.dll", options.InputFiles[0]); }
public void ResultOptionWithFilePathAndFormat() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml;format=nunit2"); Assert.True(options.Validate()); Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set"); Assert.AreEqual("tests.dll", options.InputFiles[0]); OutputSpecification spec = options.ResultOutputSpecifications[0]; Assert.AreEqual("results.xml", spec.OutputPath); Assert.AreEqual("nunit2", spec.Format); Assert.Null(spec.Transform); }
public void MissingValuesAreReported(string option) { ConsoleOptions options = new ConsoleOptions(option + "="); Assert.False(options.Validate(), "Missing value should not be valid"); Assert.AreEqual("Missing required value for option '" + option + "'.", options.ErrorMessages[0]); }
public void NoResultSuppressesAllResultSpecifications() { var options = new ConsoleOptions("test.dll", "-result:results.xml", "-noresult", "-result:nunit2results.xml;format=nunit2"); Assert.AreEqual(0, options.ResultOutputSpecifications.Count); }
public void NoInputFiles() { ConsoleOptions options = new ConsoleOptions(); Assert.True(options.Validate()); Assert.AreEqual(0, options.InputFiles.Count); }
public void TimeoutParsesIntValueCorrectly() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-timeout:5000"); Assert.True(options.Validate()); Assert.AreEqual(5000, options.DefaultTimeout); }
public void ResultOptionMayBeRepeated() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml", "-result:nunit2results.xml;format=nunit2", "-result:myresult.xml;transform=mytransform.xslt"); Assert.True(options.Validate(), "Should be valid"); var specs = options.ResultOutputSpecifications; Assert.AreEqual(3, specs.Count); var spec1 = specs[0]; Assert.AreEqual("results.xml", spec1.OutputPath); Assert.AreEqual("nunit3", spec1.Format); Assert.Null(spec1.Transform); var spec2 = specs[1]; Assert.AreEqual("nunit2results.xml", spec2.OutputPath); Assert.AreEqual("nunit2", spec2.Format); Assert.Null(spec2.Transform); var spec3 = specs[2]; Assert.AreEqual("myresult.xml", spec3.OutputPath); Assert.AreEqual("user", spec3.Format); Assert.AreEqual("mytransform.xslt", spec3.Transform); }
public void ResultOptionWithoutFileNameIsInvalid() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:"); Assert.False(options.Validate(), "Should not be valid"); Assert.AreEqual(1, options.ErrorMessages.Count, "An error was expected"); }
public void FileNameWithoutResultOptionLooksLikeParameter() { ConsoleOptions options = new ConsoleOptions("tests.dll", "results.xml"); Assert.True(options.Validate()); Assert.AreEqual(0, options.ErrorMessages.Count); Assert.AreEqual(2, options.InputFiles.Count); }
public void AssemblyAloneIsValid() { ConsoleOptions options = new ConsoleOptions("nunit.tests.dll"); Assert.True(options.Validate()); Assert.AreEqual(0, options.ErrorMessages.Count, "command line should be valid"); }
public void ExploreOptionWithoutPath() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore"); Assert.True(options.Validate()); Assert.True(options.Explore); }
public void WhenNoOptionsAreSpecified_PackageContainsWorkDirectorySettingOnly() { var options = new ConsoleOptions("test.dll"); var package = ConsoleRunner.MakeTestPackage(options); Assert.AreEqual(1, package.Settings.Count); Assert.That(package.Settings.Keys, Contains.Item("WorkDirectory")); }
public void ExploreOptionWithFilePathAndTransform() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore:results.xml;transform=myreport.xslt"); Assert.True(options.Validate()); Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set"); Assert.AreEqual("tests.dll", options.InputFiles[0]); Assert.True(options.Explore); OutputSpecification spec = options.ExploreOutputSpecifications[0]; Assert.AreEqual("results.xml", spec.OutputPath); Assert.AreEqual("user", spec.Format); Assert.AreEqual("myreport.xslt", spec.Transform); }
public void DefaultResultSpecification() { var options = new ConsoleOptions("test.dll"); Assert.AreEqual(1, options.ResultOutputSpecifications.Count); var spec = options.ResultOutputSpecifications[0]; Assert.AreEqual("TestResult.xml", spec.OutputPath); Assert.AreEqual("nunit3", spec.Format); Assert.Null(spec.Transform); }
public void TimeoutCausesErrorIfValueIsNotInteger() { ConsoleOptions options = new ConsoleOptions("tests.dll", "-timeout:abc"); Assert.False(options.Validate()); Assert.AreEqual(-1, options.DefaultTimeout); }
public void WhenDebugging_NumberOfTestWorkersMayBeOverridden() { var options = new ConsoleOptions("test.dll", "--debug", "--workers=3"); var package = ConsoleRunner.MakeTestPackage(options); Assert.That(package.Settings["DebugTests"], Is.EqualTo(true)); Assert.That(package.Settings["NumberOfTestWorkers"], Is.EqualTo(3)); }
public void NoResultSuppressesDefaultResultSpecification() { var options = new ConsoleOptions("test.dll", "-noresult"); Assert.AreEqual(0, options.ResultOutputSpecifications.Count); }