Exemplo n.º 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;
        }
Exemplo n.º 2
0
        public DefectResult GetDefect(string sId)
        {
            DefectResult dr = new DefectResult();
            int id = Convert.ToInt32(sId);

            wi = GetWorkItem(id);
            if (wi != null)
            {
                dr.id = wi.Id;
                dr.status = wi.State;
            }
            return dr;
        }
Exemplo n.º 3
0
        public DefectResult CreateBug(Defect defect)
        {
            DefectResult dr = new DefectResult();
            // gegevens uit Defect object in een work item zetten.
            wi.Fields["Title"].Value = defect.title;
            //wi.Fields["Description"].Value = defect.description;
            wi.Fields["How Found"].Value = defect.howFound;
            wi.Fields["Symptom"].Value = "<PRE>"+ defect.symptom + "</PRE>";

            if (defect.attachmentList != null)
            {
                foreach (string attachment in defect.attachmentList)
                {
                    if (File.Exists(attachment))
                    {
                        wi.Attachments.Add(new Attachment(attachment, "Added by Tosca Defect Tracker"));
                    }
                }
            }
            // static fields
            wi.Fields["BKR Priority"].Value = BKRpriority;
            wi.Fields["BKR Finding Type"].Value = BKRfindingType;

            #region Not used
            //wi.Fields["History"].Value = "";
            //wi.Fields["Iteration Path"].Value = "";
            //wi.Fields["Iteration ID"].Value = "";
            //wi.Fields["Activated Date"].Value = "";
            //wi.Fields["Activated By"].Value = "";
            //wi.Fields["Resolved Date"].Value = "";
            //wi.Fields["Resolved By"].Value = "";
            //wi.Fields["Resolved Reason"].Value = "";
            //wi.Fields["Stack Rank"].Value = "";
            //wi.Fields["Blocked"].Value = "";
            //wi.Fields["State"].Value = "";
            //wi.Fields["Changed By"].Value = "";
            //wi.Fields["Reason"].Value = "";
            //wi.Fields["Assigned To"].Value = "";
            //wi.Fields["BKR Clarify Date"].Value = "";
            //wi.Fields["Root Cause"].Value = "";
            //wi.Fields["Severity"].Value = "";
            //wi.Fields["System Info"].Value = "";
            //wi.Fields["Repro Steps"].Value = "";
            //wi.Fields["Found In Environment"].Value = "";
            //wi.Fields["Proposed Fix"].Value = "";
            //wi.Fields["BKR Clarify By"].Value = "";
            //wi.Fields["Area Path"].Value = "";
            //wi.Fields["Area ID"].Value = "";
            #endregion

            // work item valideren; controleren of alle verplichte velden gevuld zijn en of alle waarden correct zijn ingevuld
            ArrayList validationErrors = wi.Validate();

            // als er geen fouten zijn, work item opslaan en bugid ophalen
            if (validationErrors.Count == 0)
            {
                wi.Save();
                dr.id = wi.Id;
                dr.status = wi.State;
            }
            else
            {
                // foutmeldingen tonen
                foreach (Field field in validationErrors)
                {
                    System.Windows.Forms.MessageBox.Show("Validation Error in field " + field.ReferenceName);
                }
                dr.id = 0;
                dr.status = String.Empty;
            }
            return dr;
        }
Exemplo n.º 4
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;
        }