Beispiel #1
0
        public void SaveTestRunToDb(Benchmark.TestRun testRun)
        {
            if (testRun.Benchmark.ConnectionSettings.DbProvider == null)
            {
                MessageBox.Show("Database connection is not set.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                DbProviders.DbProvider provider            = testRun.Benchmark.ConnectionSettings.DbProvider;
                DbProviders.DbBenchmarkObjectWriter writer = provider.CreateBenchmarkObjectWriter();

                try
                {
                    if (writer == null)
                    {
                        throw new Exception("The selected provider does not support this operation.");
                    }

                    Cursor.Current = Cursors.WaitCursor;

                    provider.Connect();
                    writer.WriteToDb(testRun);
                    provider.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
        private void UpdateSummary()
        {
            int total     = 0;
            int processed = 0;
            int passed    = 0;
            int failed    = 0;
            int errors    = 0;

            Benchmark.TestRun testRun = TestRun;
            foreach (Benchmark.TestResult testResult in testRun.TestResults)
            {
                if (testResult is Benchmark.PlanEquivalenceTestResult planEquivalenceTestResult)
                {
                    total++;
                    if (planEquivalenceTestResult.Completed)
                    {
                        processed++;


                        bool error = false;
                        foreach (Benchmark.QueryVariantResult queryVariantResult in planEquivalenceTestResult.QueryVariantResults)
                        {
                            if (queryVariantResult.ErrorMessage != string.Empty)
                            {
                                error = true;
                                break;
                            }
                        }
                        if (error)
                        {
                            errors++;
                        }
                        else
                        {
                            if (planEquivalenceTestResult.Success)
                            {
                                passed++;
                            }
                            else
                            {
                                failed++;
                            }
                        }
                    }
                }
            }

            lblTestsProcessed.Text = Convert.ToString(processed);
            lblTestsPassed.Text    = Convert.ToString(passed);
            lblTestsFailed.Text    = Convert.ToString(failed);
            lblErrors.Text         = Convert.ToString(errors);

            lblSuccess.Text = processed > 0 ? (passed / (double)processed).ToString("p2") : string.Empty;

            if (total > 0)
            {
                progressBar.Value = processed * 100 / total;
            }
        }
 private void WriteToDatabase_Click(object sender, EventArgs e)
 {
     Benchmark.TestRun testRun = (Benchmark.TestRun)BenchmarkObject;
     Executor.Executor.Instance.SaveTestRunToDb(testRun);
 }
 private void Delete_Click(object sender, EventArgs e)
 {
     Benchmark.TestRun testRun = (Benchmark.TestRun)BenchmarkObject;
     testRun.Benchmark.TestRuns.Remove(testRun);
 }
 public TestRunTreeNode(Benchmark.TestRun testRun, BenchmarkTreeView benchmarkTreeView)
     : base(testRun, benchmarkTreeView)
 {
 }
Beispiel #6
0
        public void Prepare()
        {
            if (benchmark == null)
            {
                throw new Exception("Benchmark is not set.");
            }

            DbProviders.DbProvider db = benchmark.ConnectionSettings.DbProvider;

            testRun = new Benchmark.TestRun(benchmark);

            if (testLoops == 1)
            {
                testRun.Name = testRunName;
            }
            else
            {
                testRun.Name = string.Format("{0} ({1}/{2})", testRunName, currentLoop + 1, testLoops);
            }

            testRun.ExecutorInfo = this.GetExecutorInfoStr();
            testRun.SettingsInfo = db.GetSettingsInfo();

            foreach (Benchmark.TestGroup testGroup in benchmark.TestGroups)
            {
                Benchmark.TestGroupResult testGroupResult = new Benchmark.TestGroupResult(testRun);
                testGroupResult.TestGroupId     = testGroup.Id;
                testGroupResult.TestGroupNumber = testGroup.Number;
                testGroupResult.TestGroupName   = testGroup.Name;
                testRun.TestGroupResults.Add(testGroupResult);

                foreach (Benchmark.Configuration configuration in testGroup.Configurations)
                {
                    Benchmark.ConfigurationResult configurationResult = new Benchmark.ConfigurationResult(testRun);
                    configurationResult.ConfigurationId     = configuration.Id;
                    configurationResult.ConfigurationNumber = configuration.Number;
                    configurationResult.ConfigurationName   = configuration.Name;
                    testRun.ConfigurationResults.Add(configurationResult);

                    foreach (Benchmark.Test test in testGroup.Tests)
                    {
                        if (!test.Active)
                        {
                            continue;
                        }

                        if (test is Benchmark.PlanEquivalenceTest planEquivalenceTest)
                        {
                            if (IgnoreTest(planEquivalenceTest))
                            {
                                continue;
                            }

                            if (planEquivalenceTest.Parametrized)
                            {
                                foreach (Benchmark.Template template in planEquivalenceTest.Templates)
                                {
                                    if (IgnoreTemplate(template))
                                    {
                                        continue;
                                    }

                                    PreparePlanEquivalenceTest(planEquivalenceTest, test, testGroup, configuration, db, template);
                                }
                            }
                            else
                            {
                                PreparePlanEquivalenceTest(planEquivalenceTest, test, testGroup, configuration, db);
                            }
                        }
                        // TODO - other test types.
                    }
                }
            }

            foreach (Benchmark.Annotation annotation in benchmark.Annotations)
            {
                Benchmark.AnnotationResult annotationResult = new Benchmark.AnnotationResult(testRun);
                annotationResult.AnnotationId     = annotation.Id;
                annotationResult.AnnotationNumber = annotation.Number;
                annotationResult.AnnotationName   = annotation.Name;
                testRun.AnnotationResults.Add(annotationResult);
            }

            benchmark.TestRuns.Add(testRun);
        }