本文整理汇总了C#中ITestFilter.Pass方法的典型用法代码示例。如果您正苦于以下问题:C# ITestFilter.Pass方法的具体用法?C# ITestFilter.Pass怎么用?C# ITestFilter.Pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITestFilter
的用法示例。
在下文中一共展示了ITestFilter.Pass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CountTestCases
public override int CountTestCases( ITestFilter filter )
{
if (filter.Pass(this))
return 1;
return 0;
}
示例2: RunAllTests
private void RunAllTests(
TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
{
foreach (Test test in ArrayList.Synchronized(Tests))
{
if (filter.Pass(test))
{
RunState saveRunState = test.RunState;
if (test.RunState == RunState.Runnable && this.RunState != RunState.Runnable && this.RunState != RunState.Explicit )
{
test.RunState = this.RunState;
test.IgnoreReason = this.IgnoreReason;
}
TestResult result = test.Run(listener, filter);
suiteResult.AddResult(result);
if (saveRunState != test.RunState)
{
test.RunState = saveRunState;
test.IgnoreReason = null;
}
}
}
}
示例3: MarkTestsNotRun
private void MarkTestsNotRun(
IList tests, RunState runState, string ignoreReason, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
{
foreach (Test test in ArrayList.Synchronized(tests))
{
if (filter.Pass(test))
MarkTestNotRun(test, runState, ignoreReason, suiteResult, listener, filter);
}
}
示例4: MarkTestsFailed
private void MarkTestsFailed(
IList tests, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
{
foreach (Test test in ArrayList.Synchronized(tests))
if (filter.Pass(test))
MarkTestFailed(test, suiteResult, listener, filter);
}
示例5: CountTestCases
public override int CountTestCases(ITestFilter filter)
{
int count = 0;
if(filter.Pass(this))
{
foreach(Test test in Tests)
{
count += test.CountTestCases(filter);
}
}
return count;
}
示例6: CountTestCases
/// <summary>
/// Counts the test cases that would be run if this
/// test were executed using the provided filter.
/// </summary>
/// <param name="filter">The filter to apply</param>
/// <returns>A count of test cases</returns>
public virtual int CountTestCases(ITestFilter filter)
{
if (filter.IsEmpty)
return TestCount;
if (!isSuite)
return filter.Pass(this) ? 1 : 0;
int count = 0;
if (filter.Pass(this))
{
foreach (ITest test in Tests)
{
count += test.CountTestCases(filter);
}
}
return count;
}
示例7: CountTestCases
private int CountTestCases(ITest test, ITestFilter filter)
{
if (!test.IsSuite)
return 1;
int count = 0;
foreach (ITest child in test.Tests)
if (filter.Pass(child))
count += CountTestCases(child, filter);
return count;
}
示例8: InternalRun
protected virtual TestResult InternalRun(ITestFilter filter, TestResult result)
{
if (this.runInParallel)
{
foreach (TestRunner runner in runners)
if (filter.Pass(runner.Test))
runner.BeginRun(this, filter);
result = this.EndRun();
}
else
{
foreach (TestRunner runner in runners)
if (filter.Pass(runner.Test))
result.AddResult(runner.Run(this, filter));
}
return result;
}
示例9: FindTestUnits
private static void FindTestUnits(ITest test, ITestFilter filter,
List<TestUnitWithMetadata> result, TestRun testRun, string assemblyName = null)
{
var assembly = test as TestAssembly;
if (assembly != null)
assemblyName = assembly.TestName.FullName;
if (filter.Pass(test))
{
var isTestSuiteWithAtLeastOneTestMethod = (test.IsSuite && test.Tests != null && test.Tests.Count != 0 &&
!((ITest) test.Tests[0]).IsSuite);
if (!test.IsSuite || isTestSuiteWithAtLeastOneTestMethod)
{
List<TestUnitWithMetadata> subTests = null;
if (test.IsSuite && test.Tests != null)
{
subTests = new List<TestUnitWithMetadata>();
foreach (ITest child in test.Tests)
{
FindTestUnits(child, filter, subTests, testRun, assemblyName);
}
}
var testUnitWithMetadata = new TestUnitWithMetadata(testRun, test, assemblyName, subTests);
result.Add(testUnitWithMetadata);
}
else if ((test.Tests != null && test.Tests.Count > 0))
{
foreach (ITest child in test.Tests)
{
FindTestUnits(child, filter, result, testRun, assemblyName);
}
}
}
}
示例10: CountTestCases
/// <summary>
/// Gets a count of test cases that would be run using
/// the specified filter.
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public virtual int CountTestCases(ITestFilter filter)
{
if (filter.Pass(this))
return 1;
return 0;
}
示例11: RunAllTests
private void RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter )
{
if (Properties.Contains("Timeout"))
TestExecutionContext.CurrentContext.TestCaseTimeout = (int)Properties["Timeout"];
IDictionary settings = TestExecutionContext.CurrentContext.TestPackage.Settings;
bool stopOnError = settings.Contains("StopOnError") && (bool)settings["StopOnError"];
foreach (Test test in ArrayList.Synchronized(Tests))
{
if (filter.Pass(test))
{
RunState saveRunState = test.RunState;
if (test.RunState == RunState.Runnable && this.RunState != RunState.Runnable && this.RunState != RunState.Explicit )
{
test.RunState = this.RunState;
test.IgnoreReason = this.IgnoreReason;
}
TestResult result = test.Run(listener, filter);
log.Debug("Test result = " + result.ResultState);
suiteResult.AddResult(result);
log.Debug("Suite result = " + suiteResult.ResultState);
if (saveRunState != test.RunState)
{
test.RunState = saveRunState;
test.IgnoreReason = null;
}
if (result.ResultState == ResultState.Cancelled)
break;
if ((result.IsError || result.IsFailure || result.ResultState == ResultState.NotRunnable) && stopOnError)
break;
}
}
}
示例12: Run
public virtual TestResult Run(EventListener listener, ITestFilter filter, bool tracing, LoggingThreshold logLevel)
{
Log.Info("Run - EventListener={0}", listener.GetType().Name);
// Save active listener for derived classes
this.listener = listener;
ITest[] tests = new ITest[runners.Count];
for( int index = 0; index < runners.Count; index++ )
tests[index] = ((TestRunner)runners[index]).Test;
string name = this.testName.Name;
int count = this.CountTestCases(filter);
Log.Info("Signalling RunStarted({0},{1})", name, count);
this.listener.RunStarted(name, count);
long startTime = DateTime.Now.Ticks;
TestResult result = new TestResult(new TestInfo(testName, tests));
if (this.runInParallel)
{
foreach (TestRunner runner in runners)
if (filter.Pass(runner.Test))
runner.BeginRun(this, filter, tracing, logLevel);
result = this.EndRun();
}
else
{
foreach (TestRunner runner in runners)
if (filter.Pass(runner.Test))
result.AddResult(runner.Run(this, filter, tracing, logLevel));
}
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
result.Time = time;
this.listener.RunFinished( result );
this.testResult = result;
return result;
}
示例13: CountTestCases
/// <summary>
/// Count the test cases that pass a filter. The
/// result should match those that would execute
/// when passing the same filter to Run.
/// </summary>
/// <param name="filter">The filter to apply</param>
/// <returns>The count of test cases</returns>
public int CountTestCases(ITestFilter filter)
{
if (filter.IsEmpty)
return TestCount;
if (!IsSuite)
return filter.Pass(this) ? 1 : 0;
int count = 0;
if (filter.Pass(this))
{
count += Tests.Cast<ITest>().Sum(test => test.CountTestCases(filter));
}
return count;
}
示例14: Run
public virtual TestResult Run(EventListener listener, ITestFilter filter )
{
// Save active listener for derived classes
this.listener = listener;
ITest[] tests = new ITest[runners.Count];
for( int index = 0; index < runners.Count; index++ )
tests[index] = ((TestRunner)runners[index]).Test;
this.listener.RunStarted( this.Test.TestName.Name, this.CountTestCases( filter ) );
this.listener.SuiteStarted( this.Test.TestName );
long startTime = DateTime.Now.Ticks;
TestSuiteResult result = new TestSuiteResult( new TestInfo( testName, tests ), projectName );
result.RunState = RunState.Executed;
foreach( TestRunner runner in runners )
if ( filter.Pass( runner.Test ) )
result.AddResult( runner.Run( this, filter ) );
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
result.Time = time;
this.listener.SuiteFinished( result );
this.listener.RunFinished( result );
this.testResult = result;
return result;
}
示例15: RunAllTests
private void RunAllTests(
TestResult suiteResult, EventListener listener, ITestFilter filter )
{
if (Properties.Contains("Timeout"))
TestContext.TestCaseTimeout = (int)Properties["Timeout"];
foreach (Test test in ArrayList.Synchronized(Tests))
{
if (filter.Pass(test))
{
RunState saveRunState = test.RunState;
if (test.RunState == RunState.Runnable && this.RunState != RunState.Runnable && this.RunState != RunState.Explicit )
{
test.RunState = this.RunState;
test.IgnoreReason = this.IgnoreReason;
}
TestResult result = test.Run(listener, filter);
suiteResult.AddResult(result);
if (saveRunState != test.RunState)
{
test.RunState = saveRunState;
test.IgnoreReason = null;
}
if (result.ResultState == ResultState.Cancelled)
break;
}
}
}