예제 #1
0
        public override void CollectMetric()
        {
            var end       = DateTime.Now.AddDays(1);
            var begin     = end.AddDays(-5);
            var vso       = this.config[SolutionConfigName.VSO_NAME].ToString();
            var project   = this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString();
            var token     = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();
            var releaseId = this.config[SolutionConfigName.FUNCTIONAL_TEST_RELEASE_DEFINITION_ID].ToString();
            var releases  = ReleaseUtil.GetReleaseByReleaseDefinitionId(vso, project, begin, end, releaseId, token);

            var metricList = new List <Metric>();

            //Get release test result
            foreach (var rel in releases)
            {
                var item = TestRunUtil.GetReleaseTestRunDataModel(vso, project, releaseId, rel.id, rel.CreationDate, token);

                if (item != null)
                {
                    var detail = new Dictionary <string, object>();
                    detail["VSO"]              = item.VSO;
                    detail["Project"]          = item.Project;
                    detail["BuildOrReleaseId"] = rel.id;
                    detail["RunId"]            = item.RunId;
                    detail["PassedTestNum"]    = item.PassedTestNum;
                    detail["TotalTestNum"]     = item.TotalTestNum;
                    detail["CreationDate"]     = item.CreationDate;
                    var metric = new Metric("TestRun", MetricType.TestRun, detail);
                    metricList.Add(metric);
                }
            }
            writer.Write(metricList);
        }
예제 #2
0
        public void BuildTestRun_GetTestRunModel_Test()
        {
            var token = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();

            var TestRun = TestRunUtil.GetBuildTestRunDataModel("bizai", "BizAI", 555, token);

            Assert.AreEqual(TestRun.Count, 2);
        }
        public void ReleaseTestRun_GetTestRunModel_Test()
        {
            var token = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();

            var TestRun = TestRunUtil.GetReleaseTestRunDataModel("bizai", "BizAI", "0", 81, DateTime.Parse("2017-10-01"), token);

            Assert.AreEqual(1, TestRun.PassedTestNum);
        }
        public override void CollectMetric()
        {
            var end      = DateTime.Now.AddDays(1);
            var begin    = end.AddDays(-5);
            var vso      = this.config[SolutionConfigName.VSO_NAME].ToString();
            var project  = this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString();
            var token    = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();
            var buildIds = this.config[SolutionConfigName.OFFICIAL_BUILD_ID].ToString();

            var maxBuildId = OfficialBuildUtil.GetMaxBuildId(begin, end, vso, project, buildIds, token);
            var metricList = new List <Metric>();

            //Retrieve the previous 100 Test coverage info
            if (maxBuildId != -1)
            {
                var initBuildId = (maxBuildId - 100) < 1 ? 1 : maxBuildId - 100;

                for (var buildId = initBuildId; buildId <= maxBuildId; ++buildId)
                {
                    var runs = TestRunUtil.GetBuildTestRunDataModel(this.config[SolutionConfigName.VSO_NAME].ToString(), this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString(), buildId, token);
                    foreach (var item in runs)
                    {
                        var detail = new Dictionary <string, object>();
                        detail["VSO"]              = item.VSO;
                        detail["Project"]          = item.Project;
                        detail["BuildOrReleaseId"] = buildId;
                        detail["RunId"]            = item.RunId;
                        detail["PassedTestNum"]    = item.PassedTestNum;
                        detail["TotalTestNum"]     = item.TotalTestNum;
                        detail["CreationDate"]     = item.CreationDate;
                        var metric = new Metric("TestRun", MetricType.TestRun, detail);
                        metricList.Add(metric);
                    }
                }
                writer.Write(metricList);
            }
        }