本文整理汇总了C#中UnityTest.TestResult类的典型用法代码示例。如果您正苦于以下问题:C# TestResult类的具体用法?C# TestResult怎么用?C# TestResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestResult类属于UnityTest命名空间,在下文中一共展示了TestResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTestStarted
public static ResultDTO CreateTestStarted(TestResult test)
{
var dto = new ResultDTO(MessageType.TestStarted);
dto.testName = test.FullName;
dto.testTimeout = test.TestComponent.timeout;
return dto;
}
示例2: CreateTestFinished
public static ResultDTO CreateTestFinished(TestResult test)
{
var dto = new ResultDTO(MessageType.TestFinished);
dto.testName = test.FullName;
dto.testResult = GetSerializableTestResult(test);
return dto;
}
示例3: AddTest
public TestResult AddTest ()
{
var go = new GameObject ();
go.name = "New Test";
go.AddComponent<TestComponent>();
go.transform.hideFlags |= HideFlags.HideInInspector;
var testResult = new TestResult (go);
testList.Add(testResult);
SortTestList ();
return testResult;
}
示例4: AddTest
public TestResult AddTest ()
{
var go = new GameObject ();
go.name = "New Test";
go.AddComponent<TestComponent>();
ShowTestInHierarchy (go, true);
var testResult = new TestResult (go);
testList.Add(testResult);
SortTestList ();
return testResult;
}
示例5: GetSerializableTestResult
private static ITestResult GetSerializableTestResult(TestResult test)
{
var str = new SerializableTestResult();
str.resultState = test.ResultState;
str.message = test.messages;
str.executed = test.Executed;
str.name = test.Name;
str.fullName = test.FullName;
str.id = test.id;
str.isSuccess = test.IsSuccess;
str.duration = test.duration;
str.stackTrace = test.stacktrace;
return str;
}
示例6: GetIconForResult
public static Texture GetIconForResult ( TestResult.ResultType resultState )
{
switch (resultState)
{
case TestResult.ResultType.Success:
return Icons.successImg;
case TestResult.ResultType.Timeout:
case TestResult.ResultType.Failed:
case TestResult.ResultType.FailedException:
return Icons.failImg;
case TestResult.ResultType.Ignored:
return Icons.ignoreImg;
case TestResult.ResultType.NotRun:
default:
return Icons.unknownImg;
}
}
示例7: GetIconBasedOnResultType
private GUIContent GetIconBasedOnResultType (TestResult result)
{
if (result == null) return Icons.guiUnknownImg;
if (result.isRunning)
{
return Icons.GetSpinningIcon ();
}
if (result.resultType == TestResult.ResultType.NotRun
&& result.TestComponent.ignored)
return Icons.guiIgnoreImg;
switch (result.resultType)
{
case TestResult.ResultType.Success:
return Icons.guiSuccessImg;
case TestResult.ResultType.Timeout:
case TestResult.ResultType.Failed:
case TestResult.ResultType.FailedException:
return Icons.guiFailImg;
case TestResult.ResultType.Ignored:
return Icons.guiIgnoreImg;
case TestResult.ResultType.NotRun:
default:
return Icons.guiUnknownImg;
}
}
示例8: RemoveTest
private void RemoveTest (TestResult test)
{
var testsToDelete = new List<TestResult> { test };
if (selectedTests.Count > 1)
testsToDelete = selectedTests;
if (EditorUtility.DisplayDialog ("",
"Are you sure you want to delete " +
((testsToDelete.Count > 1) ? (testsToDelete.Count + " tests?"):(testsToDelete.Single().name + "?")),
"Delete",
"Cancel"))
{
foreach (var t in testsToDelete)
{
#if !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
Undo.DestroyObjectImmediate ((t as TestResult).go);
#else
Undo.RegisterSceneUndo ("Destroy Objects");
GameObject.DestroyImmediate (t.go);
#endif
}
testManager.DeleteTest(testsToDelete);
selectedTests.Clear ();
forceRepaint = true;
}
}
示例9: IntegrationTestLine
public IntegrationTestLine(GameObject gameObject, TestResult testResult)
: base(gameObject)
{
m_Result = testResult;
}
示例10: TestStarted
public void TestStarted(TestResult test)
{
m_Window.SetCurrentTest(test.TestComponent);
m_CurrentTest = test.TestComponent;
}
示例11: RemoveTest
private void RemoveTest (TestResult test)
{
var testsToDelete = new List<TestResult> { test };
if (selectedTests.Count > 1)
testsToDelete = selectedTests;
foreach (var t in testsToDelete)
{
#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
Undo.RegisterSceneUndo ("Destroy Tests");
GameObject.DestroyImmediate (t.TestComponent.gameObject);
#else
Undo.DestroyObjectImmediate (t.TestComponent.gameObject);
#endif
}
TestManager.InvalidateTestList ();
selectedTests.Clear ();
forceRepaint = true;
}
示例12: FinishTest
private void FinishTest(TestResult.ResultType result)
{
m_TestsProvider.FinishTest(currentTest);
var testResult = m_ResultList.Single(t => t.GameObject == currentTest.gameObject);
testResult.resultType = result;
testResult.duration = Time.time - m_StartTime;
testResult.messages = m_TestMessages;
testResult.stacktrace = m_Stacktrace;
TestRunnerCallback.TestFinished(testResult);
currentTest = null;
if (!testResult.IsSuccess
&& testResult.Executed
&& !testResult.IsIgnored) k_ResultRenderer.AddResults(Application.loadedLevelName, testResult);
}
示例13: DrawTestGroup
private bool DrawTestGroup ( TestResult testInfo, int indent )
{
EditorGUILayout.BeginHorizontal ();
GUILayout.Space (--indent * 15);
EditorGUIUtility.SetIconSize (new Vector2 (15, 15));
Color tempColor = GUI.color;
if (testInfo.isRunning)
{
var frame = Mathf.Abs (Mathf.Cos (Time.realtimeSinceStartup * 4)) * 0.6f + 0.4f;
GUI.color = new Color (1, 1, 1, frame);
}
var label = new GUIContent (testInfo.Name, GetIconBasedOnResultType (testInfo).image);
var labelRect = GUILayoutUtility.GetRect (label, EditorStyles.label, GUILayout.ExpandWidth (true));
if (labelRect.Contains (Event.current.mousePosition)
&& Event.current.type == EventType.MouseDown
&& Event.current.button == 0)
{
SelectTest (testInfo);
}
else if (labelRect.Contains (Event.current.mousePosition)
&& Event.current.type == EventType.ContextClick)
{
Event.current.Use ();
DrawContextTestMenu (testInfo);
}
bool isClassFolded = foldedGroups.Contains (testInfo);
EditorGUI.BeginChangeCheck ();
isClassFolded = !EditorGUI.Foldout (labelRect, !isClassFolded, label
,selectedTests.Contains (testInfo) ? Styles.selectedTestGroupStyle : Styles.testGroupStyle
);
if (EditorGUI.EndChangeCheck ())
{
if (isClassFolded)
foldedGroups.Add (testInfo);
else
foldedGroups.Remove (testInfo);
}
if (testInfo.isRunning) GUI.color = tempColor;
EditorGUIUtility.SetIconSize (Vector2.zero);
if (testInfo.resultType == TestResult.ResultType.Timeout)
{
GUILayout.Label (guiTimeoutIcon,
GUILayout.Width (24)
);
GUILayout.FlexibleSpace ();
}
EditorGUILayout.EndHorizontal ();
return !isClassFolded;
}
示例14: GetIconBasedOnResultType
private GUIContent GetIconBasedOnResultType (TestResult result)
{
if (result == null)
return Icons.guiUnknownImg;
if (result.TestComponent.IsTestGroup ())
{
var childrenResults = testManager.GetChildrenTestsResults (result.TestComponent);
if (childrenResults.Any (t => t.resultType == TestResult.ResultType.Failed
|| t.resultType == TestResult.ResultType.FailedException
|| t.resultType == TestResult.ResultType.Timeout))
result.resultType = TestResult.ResultType.Failed;
else if (childrenResults.Any (t => t.resultType == TestResult.ResultType.Success))
result.resultType = TestResult.ResultType.Success;
else if (childrenResults.All (t => t.TestComponent.ignored))
result.resultType = TestResult.ResultType.Ignored;
else
result.resultType = TestResult.ResultType.NotRun;
result.isRunning = childrenResults.Any (t => t.isRunning);
}
if (result.isRunning)
return Icons.guiUnknownImg;
if (result.resultType == TestResult.ResultType.NotRun
&& result.TestComponent.ignored)
return Icons.guiIgnoreImg;
switch (result.resultType)
{
case TestResult.ResultType.Success:
return Icons.guiSuccessImg;
case TestResult.ResultType.Timeout:
case TestResult.ResultType.Failed:
case TestResult.ResultType.FailedException:
return Icons.guiFailImg;
case TestResult.ResultType.Ignored:
return Icons.guiIgnoreImg;
case TestResult.ResultType.NotRun:
default:
return Icons.guiUnknownImg;
}
}
示例15: TestFinished
public void TestFinished (TestResult test)
{
currentTestNumber++;
integrationTestRunnerWindow.renderer.UpdateResults(new List<TestResult> { test });
integrationTestRunnerWindow.Repaint();
}