Exemplo n.º 1
0
        private void RunATest(TokenList tokens, string testName, bool isUnitTest)
        {
            Logger.Log("--------------------------------------------------");
            Logger.Log("  Running " + (isUnitTest ? "unit test " : "script = ") + testName);
            Logger.Log("");

            CoreGraphicsTest.variationsFailed = 0;

            GraphicsTestLoader tester = null;

            if (isUnitTest)
            {
                tokens.SetClassName(testName);
                tester = new RunScriptLoader(tokens, null);
            }
            else
            {
                tester = new RunScriptLoader(tokens, testName);
            }

            if (!tester.RunMyTests())
            {
                failedTests.Add(testName);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set the TestAssembly, launch tests in the test assembly based on args, and
        /// revert the TestAssembly value to original value.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="testAssembly"></param>
        public static void Launch(string[] args, Assembly testAssembly)
        {
            //Set TestAssembly.
            Assembly originalTestAssembly = TestAssembly;

            TestAssembly = testAssembly;

            TokenList tokens = new TokenList(args);

            foreach (Object o in tokens)
            {
                LogHeader(o.ToString());
            }
            string runAll        = tokens.GetValue("RunAll");
            string runAllScripts = tokens.GetValue("RunAllScripts");
            string dontCatch     = tokens.GetValue("DontCatch");
            string logTime       = tokens.GetValue("LogTime");
            string script        = tokens.GetValue("script");
            string className     = tokens.GetValue("Class");

            if (tokens.ContainsKey("?") || tokens.ContainsKey("help") || tokens.ContainsKey("Help"))
            {
                PrintHelp();
                return;
            }

            //Catch Exceptions on dispatcher, and rethrow on main thread
            if (dontCatch == null)
            {
                RenderingTest.catchExceptionsOnDispatcherThread = true;
            }
            else
            {
                RenderingTest.catchExceptionsOnDispatcherThread = !StringConverter.ToBool(dontCatch);
            }
            if (logTime != null)
            {
                LogTime = StringConverter.ToBool(logTime);
            }

            GraphicsTestLoader tester = null;

            if (runAll != null && StringConverter.ToBool(runAll))
            {
                tester = new RunAllLoader(tokens);
            }
            else if (runAllScripts != null && StringConverter.ToBool(runAllScripts))
            {
                tester = new RunAllLoader(tokens, false);
            }
            else if (script == null && className == null)
            {
                PrintHelp();
                return;
            }
            else
            {
                tester = new RunScriptLoader(tokens, script);
            }

            //Intercept and log any uncaught exceptions
            try
            {
                tester.RunMyTests();
            }

            catch (Exception e)
            {
                TestLog.Current.Result = TestResult.Fail;
                TestLog.Current.LogStatus("Test Failure - Unhandled Exception Caught");
                TestLog.Current.LogEvidence(e.ToString());
                Logger.LogFinalResults(1, 1);
            }

            if (RenderingTest.application != null)
            {
                RenderingTest.application.Dispatcher.BeginInvoke(
                    DispatcherPriority.Normal,
                    new DispatcherOperationCallback(Shutdown),
                    null
                    );
            }

            //revert TestAssembly.
            TestAssembly = originalTestAssembly;
        }