Пример #1
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            //klasse aanmaken om het resultaat van het defect in op te slaan
            DefectResult dr = new DefectResult();
            List<String> uidList = new List<String>();
            List<String> files = new List<String>();
            IEnumerable<DirectoryInfo> directories;

            ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;

            // plaatjes van foutieve testcases ophalen.

            //var dirinfo = new DirectoryInfo(@"C:\TOSCA_PROJECTS\ToscaCommander\Screenshots\failedTestSteps");
            var dirinfo = new DirectoryInfo(DefectTrackerSettings.Default.ToscaScreenshotFolder);
            if (dirinfo.Exists)
            {
                directories = dirinfo.GetDirectories().Where(d => d.LastWriteTime > DateTime.Now.AddDays(-1));
            }
            else
            {
                directories = null;
            }

            foreach (var ts in ee.TestCase.Items)
            {
                if (ts is TestStep)
                {
                    TestStep ts2 = ts as TestStep;
                    foreach (TestStepValue tsv in ts2.TestStepValues)
                    {
                        if (directories != null)
                        {
                            var result = directories.Where(b => b.Name == "surrogate " + tsv.UniqueId.ToString() && b.CreationTime > DateTime.Now.AddDays(-1)).Select(a => (tsv.UniqueId.ToString()));
                            foreach (string r in result)
                            {
                                uidList.Add("surrogate " + tsv.UniqueId.ToString());
                            }
                        }
                    }
                }
            }

            foreach (string dir in uidList)
            {
                files = Directory.GetFiles(DefectTrackerSettings.Default.ToscaScreenshotFolder + @"\" + dir).ToList();
            }

            SetTFSProject(ee);
            Defect defect;
            if (files.Count != 0)
            {
                defect = SetDefect(ee, files);
            }
            else
            {
                defect = SetDefect(ee);
            }

            TFSConnector tfs = new TFSConnector();
            dr = tfs.CreateBug(defect);
            tfs.DisposeTFS();
            if (dr.id != 0)
            {
                ee.ActualLog.ChangeRequestId = dr.id.ToString();
                ee.ActualLog.ChangeRequestState = dr.status;
            }
            //// start IE om de bevinding in TFS te bekijken
            Process.Start(DefectTrackerSettings.Default.TFSuri + DefectTrackerSettings.Default.TFSwebUri + dr.id.ToString());

            return null;
        }
Пример #2
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            DefectResult dr = new DefectResult();
            List<String> uidList = new List<String>();
            List<String> files = new List<String>();
            IEnumerable<DirectoryInfo> directories;

            ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;

            // get images from failed tests

            var dirinfo = new DirectoryInfo(DefectTrackerSettings.Default.ToscaScreenshotFolder);
            if (dirinfo.Exists)
            {
                directories = dirinfo.GetDirectories().Where(d => d.LastWriteTime > DateTime.Now.AddDays(-1));
            }
            else
            {
                directories = null;
            }

            foreach (var ts in ee.TestCase.Items)
            {
                if (ts is TestStep)
                {
                    TestStep ts2 = ts as TestStep;
                    foreach (TestStepValue tsv in ts2.TestStepValues)
                    {
                        if (directories != null)
                        {
                            var result = directories.Where(b => b.Name == "surrogate " + tsv.UniqueId.ToString() && b.CreationTime > DateTime.Now.AddDays(-1)).Select(a => (tsv.UniqueId.ToString()));
                            foreach (string r in result)
                            {
                                uidList.Add("surrogate " + tsv.UniqueId.ToString());
                            }
                        }
                    }
                }
            }

            foreach (string dir in uidList)
            {
                files = Directory.GetFiles(DefectTrackerSettings.Default.ToscaScreenshotFolder + @"\" + dir).ToList();
            }

            SetTFSProject(ee);
            Defect defect;
            if (files.Count != 0)
            {
                defect = SetDefect(ee, files);
            }
            else
            {
                defect = SetDefect(ee);
            }

            TFSConnector tfs = new TFSConnector();
            dr = tfs.CreateBug(defect);
            if (dr.id != 0)
            {
                ee.ActualLog.ChangeRequestId = dr.id.ToString();
                ee.ActualLog.ChangeRequestState = dr.status;
                // open browser to view work item/defect in TFS
                Process.Start(tfs.GetWorkItemUrl(dr.id).ToString());
            }
            tfs.DisposeTFS();

            return null;
        }