internal static string GetHTMLDescriptionFor(MethodOutcome testMethod)
        {
            string text = "<b>" + testMethod.Method.Name + "()</b><br>";

            switch (testMethod.State)
            {
            case TestState.NotYetRun:
                text += "Skipped";
                break;

            case TestState.Passed:
                text += "<font color=green>passed</font>";
                break;

            case TestState.Failed:
                text += "<font color=red>failed</font> with " + testMethod.OutcomeError.Exception.GetType().Name;
                break;

            case TestState.Inconclusive:
                text += "<font color=red>inconclusive</font>";
                break;

            default:
                throw new Exception("Unexpected");
            }

            return(text);
        }
        private void RunTests()
        {
            this.Title = "Unit Tests for " + new AssemblyName(this.GetType().Assembly.FullName).Name;

            if (TestRunner == null)
            {
                try {
                    OnTestRunStarted();
                }
                catch (Exception e) {
                    MethodInfo method = GetType().GetMethod("OnTestRunStarted", BindingFlags.NonPublic | BindingFlags.Instance);
                    this.m_headerOutcome = new MethodOutcome(method);
                    this.m_headerOutcome.SetOutcome(e);

                    this.m_headerView.SetHtml(TestClassResultActivity.GetHTMLDescriptionFor(this.m_headerOutcome));
                    this.m_headerView.Visibility = ViewStates.Visible;

                    this.ResultBar.SetColorByState(TestState.Failed);
                    Toast.MakeText(this, "OnTestRunStarted() notification failed.", ToastLength.Long).Show();
                    return;
                }

                this.m_headerView.Visibility = ViewStates.Gone;

                this.ResultBar.SetColorByState(TestState.Running);
                AsyncTestRunner.Run(this, this.CreateTestRunner, this.OnTestRunFinished);
            }
        }
Exemplo n.º 3
0
        internal static void StartActivity(Context ctx, MethodOutcome testMethod)
        {
            s_testMethodParam = testMethod;

            Intent i = new Intent(ctx, typeof(TestMethodResultActivity));

            //i.PutExtra(INTENT_CLASS_PARAM, testMethod.Class.Class.AssemblyQualifiedName);
            //i.PutExtra(INTENT_METHOD_PARAM, testMethod.Method.Name);
            ctx.StartActivity(i);
        }
Exemplo n.º 4
0
        private void FillActivity(MethodOutcome testMethod)
        {
            this.m_testMethod = testMethod;

            this.Title = "Result for " + this.m_testMethod.Method.Name;
            this.ResultBar.SetColorByState(this.m_testMethod.State);

            FillHeaderSection();
            FillResultSection();
            FillStackTraceSection();
        }
        private bool RunOnTestRunEnded()
        {
            try {
                OnTestRunEnded();
                return(true);
            }
            catch (Exception e) {
                MethodInfo method = GetType().GetMethod("OnTestRunEnded", BindingFlags.NonPublic | BindingFlags.Instance);
                this.m_headerOutcome = new MethodOutcome(method);
                this.m_headerOutcome.SetOutcome(e);

                this.m_headerView.SetHtml(TestClassResultActivity.GetHTMLDescriptionFor(this.m_headerOutcome));
                this.m_headerView.Visibility = ViewStates.Visible;

                this.ResultBar.SetColorByState(TestState.Failed);
                return(false);
            }
        }
Exemplo n.º 6
0
        internal static void StartActivity(Context ctx, MethodOutcome testMethod)
        {
            s_testMethodParam = testMethod;

              Intent i = new Intent(ctx, typeof(TestMethodResultActivity));
              //i.PutExtra(INTENT_CLASS_PARAM, testMethod.Class.Class.AssemblyQualifiedName);
              //i.PutExtra(INTENT_METHOD_PARAM, testMethod.Method.Name);
              ctx.StartActivity(i);
        }
Exemplo n.º 7
0
        private void FillActivity(MethodOutcome testMethod)
        {
            this.m_testMethod = testMethod;

              this.Title = "Result for " + this.m_testMethod.Method.Name;
              this.ResultBar.SetColorByState(this.m_testMethod.State);

              FillHeaderSection();
              FillResultSection();
              FillStackTraceSection();
        }