зеркало из
1
0
Форкнуть 0

Add -params option to NUnitLite

This commit is contained in:
Neil Colvin 2016-10-12 16:29:47 +08:00 коммит произвёл Chris Maddock
Родитель f061db4523
Коммит 1edc4545ee
3 изменённых файлов: 72 добавлений и 8 удалений

Просмотреть файл

@ -36,7 +36,7 @@ namespace NUnitLite.Tests
[TestFixture] [TestFixture]
public class CommandLineTests public class CommandLineTests
{ {
#region General Tests #region General Tests
[Test] [Test]
public void NoInputFiles() public void NoInputFiles()
@ -245,9 +245,9 @@ namespace NUnitLite.Tests
Assert.AreEqual("Invalid argument: -assembly:Tests.dll", options.ErrorMessages[1]); Assert.AreEqual("Invalid argument: -assembly:Tests.dll", options.ErrorMessages[1]);
} }
#endregion #endregion
#region Timeout Option #region Timeout Option
[Test] [Test]
public void TimeoutIsMinusOneIfNoOptionIsProvided() public void TimeoutIsMinusOneIfNoOptionIsProvided()
@ -279,9 +279,9 @@ namespace NUnitLite.Tests
Assert.AreEqual(-1, options.DefaultTimeout); Assert.AreEqual(-1, options.DefaultTimeout);
} }
#endregion #endregion
#region EngineResult Option #region EngineResult Option
[Test] [Test]
public void FileNameWithoutResultOptionLooksLikeParameter() public void FileNameWithoutResultOptionLooksLikeParameter()
@ -502,6 +502,64 @@ namespace NUnitLite.Tests
#endregion #endregion
#region Test Parameters
[Test]
public void SingleTestParameter()
{
var options = new NUnitLiteOptions("--params=X=5");
Assert.That(options.errorMessages, Is.Empty);
Assert.That(options.TestParameters, Is.EqualTo("X=5"));
}
[Test]
public void TwoTestParametersInOneOption()
{
var options = new NUnitLiteOptions("--params:X=5;Y=7");
Assert.That(options.errorMessages, Is.Empty);
Assert.That(options.TestParameters, Is.EqualTo("X=5;Y=7"));
}
[Test]
public void TwoTestParametersInSeparateOptions()
{
var options = new NUnitLiteOptions("-p:X=5", "-p:Y=7");
Assert.That(options.errorMessages, Is.Empty);
Assert.That(options.TestParameters, Is.EqualTo("X=5;Y=7"));
}
[Test]
public void ThreeTestParametersInTwoOptions()
{
var options = new NUnitLiteOptions("--params:X=5;Y=7", "-p:Z=3");
Assert.That(options.errorMessages, Is.Empty);
Assert.That(options.TestParameters, Is.EqualTo("X=5;Y=7;Z=3"));
}
[Test]
public void ParameterWithoutEqualSignIsInvalid()
{
var options = new NUnitLiteOptions("--params=X5");
Assert.That(options.ErrorMessages.Count, Is.EqualTo(1));
}
[Test]
public void DisplayTestParameters()
{
if (TestContext.Parameters.Count == 0)
{
Console.WriteLine("No Test Parameters were passed");
return;
}
Console.WriteLine("Test Parameters---");
foreach (var name in TestContext.Parameters.Names)
Console.WriteLine(" Name: {0} Value: {1}", name, TestContext.Parameters[name]);
}
#endregion
#region Helper Methods #region Helper Methods
//private static FieldInfo GetFieldInfo(string fieldName) //private static FieldInfo GetFieldInfo(string fieldName)
@ -518,7 +576,7 @@ namespace NUnitLite.Tests
return property; return property;
} }
#endregion #endregion
internal sealed class DefaultOptionsProviderStub : IDefaultOptionsProvider internal sealed class DefaultOptionsProviderStub : IDefaultOptionsProvider
{ {

Просмотреть файл

@ -260,7 +260,7 @@ namespace NUnitLite
#endif #endif
} }
#endregion #endregion
#region Helper Methods #region Helper Methods
@ -358,6 +358,9 @@ namespace NUnitLite
if (options.DefaultTestNamePattern != null) if (options.DefaultTestNamePattern != null)
runSettings[FrameworkPackageSettings.DefaultTestNamePattern] = options.DefaultTestNamePattern; runSettings[FrameworkPackageSettings.DefaultTestNamePattern] = options.DefaultTestNamePattern;
if (options.TestParameters != null)
runSettings[FrameworkPackageSettings.TestParameters] = options.TestParameters;
return runSettings; return runSettings;
} }
@ -380,7 +383,7 @@ namespace NUnitLite
? new OrFilter(testFilters.ToArray()) ? new OrFilter(testFilters.ToArray())
: testFilters[0]; : testFilters[0];
} }
if (options.WhereClauseSpecified) if (options.WhereClauseSpecified)
{ {

Просмотреть файл

@ -356,6 +356,9 @@
<ItemGroup> <ItemGroup>
<None Include="Properties\InBrowserSettings.xml" /> <None Include="Properties\InBrowserSettings.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.