本文整理汇总了C#中ITestCommand类的典型用法代码示例。如果您正苦于以下问题:C# ITestCommand类的具体用法?C# ITestCommand怎么用?C# ITestCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestCommand类属于命名空间,在下文中一共展示了ITestCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunContext
private TestResult RunContext( NSpecContextTest contextTest, ITestCommand command, TestStep testStep )
{
ITestContext testContext = command.StartPrimaryChildStep( testStep );
TestOutcome outcome = TestOutcome.Passed;
foreach( ITestCommand testCommand in command.Children )
{
NSpecExampleTest exampleTest = testCommand.Test as NSpecExampleTest;
if( exampleTest == null )
{
continue;
}
outcome = outcome.CombineWith( this.RunTest( contextTest, exampleTest, testCommand, testContext.TestStep ).Outcome );
}
foreach( ITestCommand testCommand in command.Children )
{
NSpecContextTest contextTestChild = testCommand.Test as NSpecContextTest;
if( contextTestChild == null )
{
continue;
}
outcome = outcome.CombineWith( this.RunContext( contextTestChild, testCommand, testContext.TestStep ).Outcome );
}
return testContext.FinishStep( outcome, null );
}
示例2: RunTest
private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
{
Test test = testCommand.Test;
progressMonitor.SetStatus(test.Name);
// The first test should be an assembly test
MSTestAssembly assemblyTest = testCommand.Test as MSTestAssembly;
TestOutcome outcome;
TestResult result;
if (assemblyTest != null)
{
ITestContext assemblyContext = testCommand.StartPrimaryChildStep(parentTestStep);
try
{
MSTestRunner runner = MSTestRunner.GetRunnerForFrameworkVersion(frameworkVersion);
outcome = runner.RunSession(assemblyContext, assemblyTest,
testCommand, parentTestStep, progressMonitor);
}
catch (Exception ex)
{
assemblyContext.LogWriter.Failures.WriteException(ex, "Internal Error");
outcome = TestOutcome.Error;
}
result = assemblyContext.FinishStep(outcome, null);
}
else
{
result = new TestResult(TestOutcome.Skipped);
}
progressMonitor.Worked(1);
return result;
}
示例3: RunImpl
protected override TestResult RunImpl( ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor )
{
using(progressMonitor.BeginTask( "Verifying Specifications", rootTestCommand.TestCount ) )
{
if( options.SkipTestExecution )
{
return SkipAll( rootTestCommand, parentTestStep );
}
else
{
ITestContext rootContext = rootTestCommand.StartPrimaryChildStep( parentTestStep );
TestStep rootStep = rootContext.TestStep;
TestOutcome outcome = TestOutcome.Passed;
foreach( ITestCommand command in rootTestCommand.Children )
{
NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
if( assemblyTest == null )
continue;
var assemblyResult = this.RunAssembly( command, rootStep );
outcome = outcome.CombineWith( assemblyResult.Outcome );
}
return rootContext.FinishStep( outcome, null );
}
}
}
示例4: RunImpl
/// <inheritdoc />
protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
ThrowIfDisposed();
using (progressMonitor.BeginTask(Resources.MbUnit2TestController_RunningMbUnitTests, 1))
{
if (progressMonitor.IsCanceled)
return new TestResult(TestOutcome.Canceled);
if (options.SkipTestExecution)
{
return SkipAll(rootTestCommand, parentTestStep);
}
else
{
IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands();
using (InstrumentedFixtureRunner fixtureRunner = new InstrumentedFixtureRunner(fixtureExplorer,
testCommands, progressMonitor, parentTestStep))
{
return fixtureRunner.Run();
}
}
}
}
示例5: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
return RunTest(rootTestCommand, parentTestStep, options, progressMonitor);
}
}
示例6: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
// Note: We do not check options.SkipTestExecution here because we want to build up
// the tree of data-driven test steps. So we actually check it later on in the
// PatternTestExecutor. This is different from framework adapters
// at this time (because they do not generally support dynamically generated data-driven tests).
Sandbox sandbox = new Sandbox();
EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
try
{
progressMonitor.Canceled += canceledHandler;
TestAssemblyExecutionParameters.Reset();
PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);
// Inlined to minimize stack depth.
var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
action.Run();
return action.Result;
}
finally
{
progressMonitor.Canceled -= canceledHandler;
sandbox.Dispose();
}
}
}
示例7: SetUp
public void SetUp()
{
testCommand = MockRepository.GenerateStub<ITestCommand>();
testName = new TestName { TestID = new TestID(), FullName = "fullName" };
var testCommandsByTestName = new Dictionary<TestName, ITestCommand> { { testName, testCommand } };
testFilter = new NUnitTestFilter(testCommandsByTestName);
test = MockRepository.GenerateStub<ITest>();
}
示例8: NuwaTestCommand
public NuwaTestCommand(ITestCommand innerCommand)
{
if (innerCommand == null)
{
throw new ArgumentNullException("innerCommand");
}
_proxy = innerCommand;
}
示例9: OnTestStart
static bool OnTestStart(ITestCommand command, ExecutorCallback callback)
{
XmlNode node = command.ToStartXml();
if (node != null)
callback.Notify(node.OuterXml);
return callback.ShouldContinue();
}
示例10: RunChildTests
private static TestResult RunChildTests(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
{
ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);
bool passed = true;
foreach (ITestCommand child in testCommand.Children)
passed &= RunTest(child, testContext.TestStep, progressMonitor).Outcome.Status == TestStatus.Passed;
return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
}
示例11: RunAll
private void RunAll(IProgressMonitor progressMonitor, ITestCommand rootTestCommand)
{
using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
{
using (subProgressMonitor.BeginTask("Running the tests.", rootTestCommand.TestCount))
{
RunTest(rootTestCommand, null, subProgressMonitor);
}
}
}
示例12: Run
/// <summary>
/// Runs the tests.
/// </summary>
/// <remarks>
/// <para>
/// This method can be called at most once during the lifetime of a test controller.
/// </para>
/// </remarks>
/// <param name="rootTestCommand">The root test monitor.</param>
/// <param name="parentTestStep">The parent test step, or null if starting a root step.</param>
/// <param name="options">The test execution options.</param>
/// <param name="progressMonitor">The progress monitor.</param>
/// <returns>The combined result of the root test command.</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="rootTestCommand"/>
/// <paramref name="progressMonitor"/>, or <paramref name="options"/> is null.</exception>
public TestResult Run(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
if (rootTestCommand == null)
throw new ArgumentNullException("rootTestCommand");
if (progressMonitor == null)
throw new ArgumentNullException("progressMonitor");
if (options == null)
throw new ArgumentNullException("options");
return RunImpl(rootTestCommand, parentTestStep, options, progressMonitor);
}
示例13: WrapsPassedInCommandIntoFixtureCommand
public void WrapsPassedInCommandIntoFixtureCommand([Frozen] Dictionary<MethodInfo, object> fixtures, FixtureSet sut, ITestCommand command)
{
var result = sut.ApplyFixturesToCommand(command);
Assert.IsType<FixtureCommand>(result);
var fixtureCommand = (FixtureCommand) result;
Assert.Same(command, fixtureCommand.InnerCommand);
//can't do anything else since fixtures property is not exposed
var savedFixtures = typeof (FixtureCommand).GetField("fixtures", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(fixtureCommand);
Assert.Same(fixtures, savedFixtures);
}
示例14: OnTestStart
static bool OnTestStart(ITestCommand command, ICallbackEventHandler callback)
{
if (callback == null)
return true;
XmlNode node = command.ToStartXml();
if (node != null)
callback.RaiseCallbackEvent(node.OuterXml);
return bool.Parse(callback.GetCallbackResult());
}
示例15: RunTest
private TestResult RunTest(ITestCommand testCommand, TestStep parentTestStep,
TestExecutionOptions options, IProgressMonitor progressMonitor)
{
// NOTE: This method has been optimized to minimize the total stack depth of the action
// by inlining blocks on the critical path that had previously been factored out.
using (TestController testController = testControllerProvider(testCommand.Test))
{
if (testController != null)
{
try
{
using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(testCommand.TestCount))
{
// Calling RunImpl directly instead of Run to minimize stack depth
// because we already know the arguments are valid.
return testController.RunImpl(testCommand, parentTestStep, options, subProgressMonitor);
}
}
catch (Exception ex)
{
ITestContext context = testCommand.StartPrimaryChildStep(parentTestStep);
context.LogWriter.Failures.WriteException(ex, "Fatal Exception in test controller");
return context.FinishStep(TestOutcome.Error, null);
}
}
}
// Enter the scope of the test and recurse until we find a controller.
progressMonitor.SetStatus(testCommand.Test.FullName);
ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);
TestOutcome outcome = TestOutcome.Passed;
foreach (ITestCommand monitor in testCommand.Children)
{
if (progressMonitor.IsCanceled)
break;
TestResult childResult = RunTest(monitor, testContext.TestStep, options, progressMonitor);
outcome = outcome.CombineWith(childResult.Outcome).Generalize();
}
if (progressMonitor.IsCanceled)
outcome = TestOutcome.Canceled;
TestResult result = testContext.FinishStep(outcome, null);
progressMonitor.Worked(1);
return result;
}