本文整理汇总了C#中ITestFilter类的典型用法代码示例。如果您正苦于以下问题:C# ITestFilter类的具体用法?C# ITestFilter怎么用?C# ITestFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestFilter类属于命名空间,在下文中一共展示了ITestFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.SuiteStarted(this.TestName);
var suiteListener = new MuteSuiteListener(listener);
var fixtureResult = base.Run(suiteListener, TestFilter.Empty);
var testResult = fixtureResult.Results[0] as TestResult;
if (testResult != null)
{
if (testResult.IsFailure || testResult.IsError)
{
fixtureResult.SetResult(testResult.ResultState,
testResult.Message,
testResult.StackTrace);
}
if (testResult.IsSuccess)
{
fixtureResult.Success();
}
}
listener.SuiteFinished(fixtureResult);
return fixtureResult;
}
示例2: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
var result = new TestResult(this);
lock (testClosure) {
try {
testClosure.TestMethod();
TestNonExceptionCondition(result);
} catch (IgnoreException iex) {
result.Ignore(iex.Message);
} catch (InconclusiveException icex) {
result.Invalid(icex.Message);
} catch (Exception ex) {
TestExceptionCondition(result, ex);
}
try {
testClosure.TearDown();
} catch (Exception ex) {
result.Failure("Exception in tear-down: "+ex.Message, ex.StackTrace);
}
}
listener.TestFinished(result);
return result;
}
示例3: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
using (new global::NUnit.Core.TestContext())
{
var testResult = new TestResult(this);
Log.Debug("Test Starting: " + TestName.FullName);
listener.TestStarted(TestName);
var stopwatch = new Stopwatch();
stopwatch.Start();
switch (RunState)
{
case RunState.Runnable:
case RunState.Explicit:
DoTest(_test, testResult);
break;
case RunState.NotRunnable:
testResult.Invalid(IgnoreReason);
break;
case RunState.Ignored:
testResult.Ignore(IgnoreReason);
break;
default:
testResult.Skip(IgnoreReason);
break;
}
stopwatch.Stop();
testResult.Time = stopwatch.Elapsed.Seconds;
listener.TestFinished(testResult);
return testResult;
}
}
示例4: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
var successCount = 0;
TestResult failureResult = null;
for (var i = 0; i < this.tryCount; i++)
{
var result = base.Run(listener, filter);
if (!TestFailed(result))
{
if (i == 0)
{
return result;
}
if (++successCount >= this.requiredPassCount)
{
return result;
}
}
else
{
failureResult = result;
}
}
return failureResult;
}
示例5: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
if (this.Parent != null)
this.Fixture = this.Parent.Fixture;
return base.Run(listener, filter);
}
示例6: CountTestCases
public override int CountTestCases( ITestFilter filter )
{
if (filter.Pass(this))
return 1;
return 0;
}
示例7: Run
public TestResult Run (EventListener listener, ITestFilter filter, string path, string suiteName, List<string> supportAssemblies, string testRunnerType, string testRunnerAssembly)
{
InitSupportAssemblies (supportAssemblies);
if (filter == null)
filter = TestFilter.Empty;
TestRunner tr;
if (!string.IsNullOrEmpty (testRunnerType)) {
Type runnerType;
if (string.IsNullOrEmpty (testRunnerAssembly))
runnerType = Type.GetType (testRunnerType, true);
else {
var asm = Assembly.LoadFrom (testRunnerAssembly);
runnerType = asm.GetType (testRunnerType);
}
tr = (TestRunner)Activator.CreateInstance (runnerType);
} else
tr = new RemoteTestRunner ();
TestPackage package = new TestPackage (path);
if (!string.IsNullOrEmpty (suiteName))
package.TestName = suiteName;
tr.Load (package);
return tr.Run (listener, filter, false, LoggingThreshold.All);
}
示例8: Run
/// <summary>
/// Override Run, setting Fixture to that of the Parent.
/// </summary>
/// <param name="listener"></param>
/// <param name="filter"></param>
/// <returns></returns>
public override TestResult Run(EventListener listener, ITestFilter filter)
{
if (this.Parent != null)
{
this.Fixture = this.Parent.Fixture;
TestSuite suite = this.Parent as TestSuite;
if (suite != null)
{
this.setUpMethods = suite.GetSetUpMethods();
this.tearDownMethods = suite.GetTearDownMethods();
}
}
// DYNAMIC: Get the parameters, and add the methods here.
TestResult result = base.Run(listener, filter);
if (this.isTheory && result.ResultState == ResultState.Inconclusive)
result.SetResult(
ResultState.Failure,
this.TestCount == 0
? "No test cases were provided"
: "All test cases were inconclusive",
null);
this.Fixture = null;
this.setUpMethods = null;
this.tearDownMethods = null;
return result;
}
示例9: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
TestSuiteResult suite_result = new TestSuiteResult (new TestInfo (this), TestName.FullName);
DebuggerTestHost host = DebuggerTestHost.Create ();
if (host == null) {
TestCaseResult error = new TestCaseResult (new TestInfo (this));
string msg = String.Format ("Failed to create DebuggerTestHost in {0}", FixtureType.Name);
error.Failure (msg, null, FailureSite.Parent);
suite_result.AddResult (error);
return suite_result;
}
int timeout;
if (Attribute.Timeout != 0)
timeout = Attribute.Timeout;
else
timeout = DebuggerTestAddIn.DefaultTimeout;
int repeat = 1;
if (Attribute.Repeat != 0)
repeat = Attribute.Repeat;
try {
for (int i = 0; i < repeat; i++) {
if (!host.Run (new TestInfo (this), suite_result, Type.AssemblyQualifiedName, listener, filter, timeout))
break;
}
return suite_result;
} finally {
host.Dispose ();
}
}
示例10: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
using ( new DirectorySwapper( Path.GetDirectoryName( TestFixtureBuilder.GetAssemblyPath( FixtureType ) ) ) )
{
return base.Run(listener, filter);
}
}
示例11: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(base.TestName);
long ticks = DateTime.Now.Ticks;
TestResult testResult = new TestResult(this);
Exception existingError = null;
_globalSetup.PrepareForTestPosition(Position, out existingError);
if (existingError != null)
{
TestResultUtil.Error(testResult, existingError, null, FailureSite.SetUp);
}
else
{
List<string> traceMessages = null;
try
{
RunTestMethod(testResult, out traceMessages);
}
catch (Exception e)
{
var globalTraceMessages = _globalSetup.GetTraceMessages();
TestResultUtil.Error(testResult, e, globalTraceMessages.Concat(traceMessages));
}
}
double num3 = ((double)(DateTime.Now.Ticks - ticks)) / 10000000.0;
testResult.Time = num3;
listener.TestFinished(testResult);
return testResult;
}
示例12: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
using ( new DirectorySwapper( AssemblyHelper.GetDirectoryName( FixtureType.Assembly ) ) )
{
return base.Run(listener, filter);
}
}
示例13: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(base.TestName);
long ticks = DateTime.Now.Ticks;
var testResult = new TestResultShim();
Exception existingError = null;
_globalSetup.PrepareForTestPosition(Position, out existingError);
if (existingError != null)
{
TestResultUtil.Error(testResult, TestExtensions.GetMultilineName(this), existingError, null, TestResultShim.Site.SetUp);
}
else
{
List<string> traceMessages = null;
try
{
RunTestMethod(testResult, out traceMessages);
}
catch (Exception e)
{
var globalTraceMessages = _globalSetup.GetTraceMessages();
TestResultUtil.Error(testResult, TestExtensions.GetMultilineName(this), e, globalTraceMessages.Concat(traceMessages));
}
}
var nunitTestResult = new TestResult(this);
NativeTestResult.ApplyToNunitResult(testResult, nunitTestResult);
nunitTestResult.Time = ((DateTime.Now.Ticks - ticks)) / 10000000.0;
listener.TestFinished(nunitTestResult);
return nunitTestResult;
}
示例14: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
test.Parent = Parent;
TestResult result = null;
for (var i = 1; i < retryCount; i++)
{
try
{
result = test.Run(listener, filter);
if (result.IsFailure || result.IsError)
{
var message = string.Format("Rerunning '{0}'", TestName);
Log.Info(message); Console.WriteLine(message);
result = test.Run(listener, filter);
}
}
// In Case SetUp or TearDown failed
catch (Exception e)
{
Log.Info(e.Message); Console.WriteLine(e);
}
}
return result;
}
示例15: Run
public UnitTestResult Run (IRemoteEventListener listener, ITestFilter filter, string path, string suiteName, List<string> supportAssemblies)
{
NUnitTestRunner runner = GetRunner (path);
EventListenerWrapper listenerWrapper = listener != null ? new EventListenerWrapper (listener) : null;
TestResult res = runner.Run (listenerWrapper, filter, path, suiteName, supportAssemblies);
return listenerWrapper.GetLocalTestResult (res);
}