本文整理汇总了C#中NUnit.Core.TestResult.Success方法的典型用法代码示例。如果您正苦于以下问题:C# TestResult.Success方法的具体用法?C# TestResult.Success怎么用?C# TestResult.Success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Core.TestResult
的用法示例。
在下文中一共展示了TestResult.Success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Merge
/// <summary>
/// Merges the specified other.
/// </summary>
/// <param name="source"> </param>
/// <param name="target"> </param>
public void Merge(TestResult source, TestResult target)
{
var mergedType = GetType(target);
var otherType = GetType(source);
if (mergedType == TestType.Project && otherType == TestType.Project)
{
if (string.IsNullOrEmpty(target.FullName) && !string.IsNullOrEmpty(source.FullName))
{
target.Test.TestName.FullName = source.FullName;
target.Test.TestName.Name = source.Name;
}
}
if (mergedType != otherType)
throw new NotSupportedException("Only merging of results with same test type are supported");
if (!target.IsSuccess && source.IsSuccess)
{
target.Success(source.Message);
target.SetAgentName(source.GetAgentName());
}
MergeChildren(source, target);
}
示例2: CreateTestResultFromExpectation
TestResult CreateTestResultFromExpectation(IExpectation expectation)
{
var result = new TestResult(new TestName { Name = expectation.Message });
if (expectation.IsFail)
result.Failure(expectation.ToString(), "");
else if (expectation.IsPass)
result.Success();
else if (expectation.IsPending)
result.Ignore(expectation.ToString(), "");
return result;
}
示例3: RunTestMethod
public override void RunTestMethod(TestResult testResult)
{
using (var runner = new Runner(Spec))
{
var example = runner.Run(() => RunBaseTestMethod(testResult), new TestResultExampleReporter(testResult));
if (example.IsFail)
testResult.Failure(GetTestResultMessageForResultState(testResult, ResultState.Failure, "Failing"), "");
if (example.IsPass)
testResult.Success();
if (example.IsPending)
testResult.Ignore(GetTestResultMessageForResultState(testResult, ResultState.Ignored, "Pending"));
}
}
示例4: DoTest
private static void DoTest(Action test, TestResult testResult)
{
try
{
test();
testResult.Success();
}
catch(ThreadAbortException e)
{
Thread.ResetAbort();
HandleException(e, testResult);
}
catch (Exception e)
{
HandleException(e, testResult);
}
}
示例5: CreateTestResult
public TestResult CreateTestResult(TestType type, string fullName,
ResultState state = ResultState.Success,
Func<IEnumerable<TestResult>> children = null,
string stackTrace = null,
string description = null,
IList categories = null,
string agentName = null)
{
description = description ?? RandomValuesGenerator.GetRandomValue<string>();
agentName = agentName ?? RandomValuesGenerator.GetRandomValue<string>();
var splitted = (fullName ?? string.Empty).Split(new[]{'.'}, StringSplitOptions.RemoveEmptyEntries);
var childResults = children != null ? children() : new TestResult[0];
var testResult = new TestResult(new TestInfoWrapper
{
TestName = new TestName
{
FullName = fullName,
Name = splitted.Length > 0 ? splitted[splitted.Length - 1] : string.Empty
},
Categories = categories,
IsSuite = type != TestType.TestMethod,
TestCount = type == TestType.TestMethod ? 1 : RandomValuesGenerator.GetRandomValue<int>(),
TestType = type.ToString()
})
{
AssertCount = 1,
Time = RandomValuesGenerator.GetRandomValue<double>()
};
if (state != ResultState.Success)
testResult.SetResult(state,
description,
stackTrace);
else
testResult.Success(description);
testResult.SetAgentName(agentName);
foreach (var childResult in childResults)
{
testResult.AddResult(childResult);
}
return testResult;
}
示例6: ApplyToNunitResult
public static TestResult ApplyToNunitResult(TestResultShim shim, TestResult result)
{
switch (shim.Status)
{
case TestResultShim.Result.Successs:
result.Success();
break;
case TestResultShim.Result.Error:
result.SetResult(ResultState.Error, shim.FailureReason, shim.FailureStackTrace, GetNUnitFailureSite(shim.FailureSite));
break;
default:
throw new ArgumentOutOfRangeException();
}
result.Time = shim.ExecutionTime.Seconds;
return result;
}
示例7: NUnitTestResult
private TestResult NUnitTestResult(IResultSummary concordionResult)
{
var testResult = new TestResult(this);
if (concordionResult.HasExceptions)
{
testResult.Error(new NUnitException("Exception in Concordion test: please see Concordion test reports"));
}
else if (concordionResult.HasFailures)
{
testResult.Failure("Concordion Test Failures: " + concordionResult.FailureCount,
"for stack trace, please see Concordion test reports");
} else
{
testResult.Success();
}
return testResult;
}
示例8: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
// TODO: Implement logic required for filtering.
listener.TestStarted(this.TestName);
long startTime = DateTime.Now.Ticks;
var result = new TestResult(this);
try
{
_engine.ExecuteScriptFile(_scriptPath);
result.Success();
}
catch (AssertionException assertEx)
{
result.SetResult(ResultState.Failure, assertEx.Message, assertEx.StackTrace, FailureSite.Test);
}
catch (InconclusiveException inconclusiveEx)
{
result.SetResult(ResultState.Inconclusive, inconclusiveEx.Message, inconclusiveEx.StackTrace);
}
catch (Exception ex)
{
result.Error(ex);
}
finally
{
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
result.Time = time;
listener.TestFinished(result);
}
return result;
}
示例9: RunTestMethod
private void RunTestMethod(TestResult testResult)
{
object fixture = this.method.IsStatic ? null : this.Fixture;
object result = Reflect.InvokeMethod( this.method, fixture, this.arguments );
if (this.hasExpectedResult)
NUnitFramework.Assert.AreEqual(expectedResult, result);
testResult.Success();
}
示例10: NUnitTestResult
private TestResult NUnitTestResult(ResultSummary concordionResult, string resultPath)
{
var testResult = new TestResult(this);
if (concordionResult.hasExceptions())
{
testResult.Error(new NUnitException("Exception in Concordion test: please see Concordion test reports"));
}
else if (concordionResult.getFailureCount() > 0)
{
testResult.Failure("Concordion Test Failures: " + concordionResult.getFailureCount(),
"for stack trace, please see Concordion test reports");
} else
{
testResult.Success(resultPath);
}
return testResult;
}
示例11: RunTestCase
private void RunTestCase( TestResult testResult )
{
try
{
object result = RunTestMethod(testResult);
if (this.hasExpectedResult)
NUnitFramework.Assert.AreEqual(expectedResult, result);
testResult.Success();
if (testResult.IsSuccess && exceptionProcessor != null)
exceptionProcessor.ProcessNoException(testResult);
}
catch (Exception ex)
{
if (ex is ThreadAbortException)
Thread.ResetAbort();
if (exceptionProcessor == null)
RecordException(ex, testResult, FailureSite.Test);
else
exceptionProcessor.ProcessException(ex, testResult);
}
}
示例12: RunTest
public override TestResult RunTest ()
{
var result = new TestResult (TestName);
var module = GetModule ();
if (module == null)
return result;
Reflect.InvokeMethod (Method, Fixture, new object [] { module });
result.Success ();
return result;
}
示例13: SetResult_Success
public void SetResult_Success()
{
TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo );
TestResult result = new TestResult( testCaseInfo );
result.Success();
node.Result = result;
Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.ImageIndex );
Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex );
Assert.AreEqual( "Success", node.StatusText );
}
示例14: doTestCase
private void doTestCase(TestResult testResult)
{
object fixture = this.Method.IsStatic ? null : this.Fixture;
// Ugh... RunTestMethod is publicly overridable, but depends on a whole bunch of internal/private detail, so it's not really very overridable...
var arguments = Helper.ReadPrivateField<object[]>(this, "arguments");
var hasExpectedResult = Helper.ReadPrivateField<bool>(this, "hasExpectedResult");
var expectedResult = Helper.ReadPrivateField<object>(this, "expectedResult");
object result = Helper.InvokeMethodDirect(this.Method, fixture, arguments);
if (hasExpectedResult)
NUnitFramework.Assert.AreEqual(expectedResult, result);
testResult.Success();
}
示例15: TestNonExceptionCondition
private void TestNonExceptionCondition(TestResult result)
{
if (! TestShouldThrowException()) result.Success();
else result.Failure("The behaviour did not throw an exception", "");
}