public void TestResult() { TestCaseDummy local = new TestCaseDummy("TestMethod"); UUnitTestResult result = local.Run(); UUnitAssert.Equals("1 run, 0 failed", result.Summary(), "testResult"); }
public void TestFailure() { TestCaseDummy local = new TestCaseDummy("TestFail"); UUnitTestResult result = local.Run(); UUnitAssert.Equals("1 run, 1 failed", result.Summary(), "Failure"); }
public void Start() { suite = new UUnitTestSuite (); suite.AddAll (typeof(DiagramTest)); result = suite.Run(); Debug.Log (result.Summary ()); }
public void Run(UUnitTestResult testResult) { setUpStopwatch.Start(); SetUp(); setUpStopwatch.Stop(); testResult.TestStarted(); bool success = false; string message = null; try { Type type = this.GetType(); MethodInfo method = type.GetMethod(testMethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); eachTestStopwatch.Reset(); eachTestStopwatch.Start(); method.Invoke(this, null); eachTestStopwatch.Stop(); success = true; } catch (TargetInvocationException e) { message = e.InnerException.ToString(); success = false; } finally { tearDownStopwatch.Start(); TearDown(); tearDownStopwatch.Stop(); } testResult.TestComplete(success, eachTestStopwatch.ElapsedMilliseconds, message); }
public UUnitTestResult RunAll() { UUnitTestResult res = new UUnitTestResult(); foreach (Type t in testCases) { string typeName = t.Name; foreach (MethodInfo m in t.GetMethods()) { if (m.Name.StartsWith("Test") && m.GetParameters().Length == 0) { ConstructorInfo[] p = t.GetConstructors(); for (int i = 0; i < p.Length; i++) { if (p[i].GetParameters().Length == 0) { DateTime startTime1 = DateTime.Now; DateTime stopTime1 = DateTime.Now; UUnitAssertException ae = null; string errMsg = null; bool success = true; try { UUnitTestCase unitTest = (UUnitTestCase)p[i].Invoke(new object[0]); unitTest.Setup(); startTime1 = DateTime.Now; m.Invoke(unitTest, new object[0]); stopTime1 = DateTime.Now; unitTest.TearDown(); } catch (System.Reflection.TargetInvocationException e) { stopTime1 = DateTime.Now; ae = e.InnerException as UUnitAssertException; success = false; if (ae == null) { errMsg = e.InnerException.ToString(); } else { errMsg = ae.Message; } } catch (System.Exception ex) { stopTime1 = DateTime.Now; success = false; errMsg = ex.ToString(); } TimeSpan duration1 = stopTime1 - startTime1; double timeSpendMillis = duration1.TotalMilliseconds; res.AddTestResult(typeName, m.Name, success, ae, timeSpendMillis, errMsg); } } } } } return(res); }
public void TestTestSuiteAddAll() { UUnitTestSuite suite = new UUnitTestSuite(); suite.AddAll(typeof(TestCaseDummy)); UUnitTestResult result = suite.Run(); UUnitAssert.Equals("2 run, 1 failed", result.Summary(), "Suite"); }
void Start() { UUnitTestSuite suite = new UUnitTestSuite(); suite.AddAll(typeof(SpriteAnimationTestCase)); UUnitTestResult result = suite.Run(); Debug.Log(result.Summary()); }
void RunTests() { UUnitTestSuite testSuite = new UUnitTestSuite(); testSuite.AddAll(typeof(ScoreControllerTestCase)); UUnitTestResult result = testSuite.Run(); Debug.Log(result.Summary()); }
public void Start() { UUnitTestSuite suite = new UUnitTestSuite(); suite.AddAll(typeof(TestCaseTest)); UUnitTestResult result = suite.Run(); Debug.Log(result.Summary()); }
public void TestTestSuiteAdd() { UUnitTestSuite suite = new UUnitTestSuite(); suite.Add(new TestCaseDummy("TestMethod")); suite.Add(new TestCaseDummy("TestFail")); UUnitTestResult result = suite.Run(); UUnitAssert.Equals("2 run, 1 failed", result.Summary(), "Suite"); }
private static void RunAllTests() { ClearDebugLog(); UUnitTestSuite suite = new UUnitTestSuite(); FindAndAddAllTestCases(suite); UUnitTestResult result = suite.Run(); Debug.Log(result.Summary()); }
public UUnitTestResult Run(UUnitTestResult testResult) { if (testResult == null) { testResult = new UUnitTestResult (); } foreach (UUnitTestCase test in tests) { testResult = test.Run (testResult); } return testResult; }
/// <summary> /// Initialization /// </summary> void Start() { UUnitTestSuite suite = new UUnitTestSuite(); suite.Add(typeof(PriorityQueueTest)); suite.Add(typeof(ShortestPathTest)); UUnitTestResult result = suite.RunAll(); Debug.Log("Result: " + result.Summary()); }
public UUnitTestResult Run(UUnitTestResult testResult) { if (testResult == null) { testResult = new UUnitTestResult(); } foreach (UUnitTestCase test in tests) { testResult = test.Run(testResult); } return(testResult); }
public UUnitTestResult RunAll(){ UUnitTestResult res = new UUnitTestResult(); foreach (Type t in testCases){ string typeName = t.Name; foreach (MethodInfo m in t.GetMethods()){ if (m.Name.StartsWith("Test") && m.GetParameters().Length==0){ ConstructorInfo[] p = t.GetConstructors(); for (int i=0;i<p.Length;i++) { if (p[i].GetParameters().Length==0){ DateTime startTime1 = DateTime.Now; DateTime stopTime1 = DateTime.Now; UUnitAssertException ae = null; string errMsg = null; bool success = true; try { UUnitTestCase unitTest = (UUnitTestCase)p[i].Invoke(new object[0]); unitTest.Setup(); startTime1 = DateTime.Now; m.Invoke(unitTest, new object[0]); stopTime1 = DateTime.Now; unitTest.TearDown(); } catch (System.Reflection.TargetInvocationException e){ stopTime1 = DateTime.Now; ae = e.InnerException as UUnitAssertException; success = false; if (ae==null){ errMsg = e.InnerException.ToString(); } else { errMsg = ae.Message; } } catch (System.Exception ex) { stopTime1 = DateTime.Now; success = false; errMsg = ex.ToString(); } TimeSpan duration1 = stopTime1 - startTime1; double timeSpendMillis = duration1.TotalMilliseconds; res.AddTestResult(typeName,m.Name,success, ae, timeSpendMillis, errMsg); } } } } } return res; }
public UUnitTestResult Run(UUnitTestResult testResult) { if (testResult == null) { testResult = new UUnitTestResult (); } SetUp (); testResult.TestStarted (); try { Type type = this.GetType (); MethodInfo method = type.GetMethod (testMethodName); method.Invoke (this, null); } catch (TargetInvocationException e) { testResult.TestFailed (); Debug.Log (e.InnerException); } finally { TearDown (); } return testResult; }
public UUnitTestResult Run(UUnitTestResult testResult) { if (testResult == null) { testResult = new UUnitTestResult(); } SetUp(); testResult.TestStarted(); try { Type type = this.GetType(); MethodInfo method = type.GetMethod(testMethodName); method.Invoke(this, null); } catch (TargetInvocationException e) { testResult.TestFailed(); Debug.Log(e.InnerException); } finally { TearDown(); } return(testResult); }
static int Main(string[] args) { for (int i = 0; i < args.Length; i++) { if (args[i] == "-testInputsFile" && (i + 1) < args.Length) { string filename = args[i + 1]; if (File.Exists(filename)) { string testInputsFile = File.ReadAllText(filename); var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var testInputs = serializer.Deserialize <Dictionary <string, string> >(new JsonTextReader(new StringReader(testInputsFile))); PlayFabApiTest.SetTitleInfo(testInputs); } else { Console.WriteLine("Loading testSettings file failed: " + filename); Console.WriteLine("From: " + Directory.GetCurrentDirectory()); } } } UUnitTestSuite suite = new UUnitTestSuite(); // With this call, we should only expect the unittests within PlayFabSDK to run - This could be expanded by adding other assemblies manually foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { suite.FindAndAddAllTestCases(assembly, typeof(UUnitTestCase)); } suite.RunAllTests(); UUnitTestResult result = suite.GetResults(); Console.WriteLine(result.Summary()); Console.WriteLine(); return(result.AllTestsPassed() ? 0 : 1); }