/// <summary>
        /// This method contains the logic performed when the context menu is selected.
        /// </summary>
        /// <param name="objectToExecuteOn">TCObject on which the context menu task is performed.</param>
        /// <param name="taskContext">Task Context of the AddOn Task.</param>
        /// <returns>TCObject Instance</returns>
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            TCProject workspaceRoot = objectToExecuteOn as TCProject;
            //Opens the File Upload dialog.
            string filepath = taskContext.GetFilePath("Upload UFT Object archive");
            //Instantiation of this object is mandatory. This class contains the necessary methods for migration.
            ToscaObjectDefinition toscaObjects = new ToscaObjectDefinition();

            try
            {
                //Instantiates the MigrationTask class that contains the business logic of migration.
                MigrationTask migrationObjectImporter = new MigrationTask(toscaObjects, Engine.Html);
                //Entry point of MigrationTask class.
                migrationObjectImporter.ProcessArchive(filepath);

                //Calling this method is mandatory. It outputs the file containing the migrated object information.
                string outputFilePath = toscaObjects.FinishObjectDefinitionTask();
                //Imports the output file from MigrationTask.
                workspaceRoot?.ImportExternalObjects(outputFilePath);
                //Cleans the migration metafiles.
                Directory.Delete(toscaObjects.MigrationFolderPath, true);
            }
            catch (Exception e)
            {
                //Pops-up the error message in case of any error in Migration.
                taskContext.ShowErrorMessage("Exception occured", e.Message);
            }
            return(null);
        }
Example #2
0
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;
     ee.ActualLog.Comment = String.Empty;
     ee.ActualLog.ChangeRequestId = String.Empty;
     return null;
 }
Example #3
0
        public override TCObject Execute(TCObject item, TCAddOnTaskContext taskContext)
        {
            var config = ((OwnedItem)item).GetJiraConfig();

            string[] props = new string[] { };
            if (item.GetType() == typeof(RequirementSet))
            {
                props = ToscaHelpers.GetPropertyNames("requirement");
            }

            if (item.GetType() == typeof(TCFolder))
            {
                var folder = item as TCFolder;
                props = ToscaHelpers.GetPropertyNames(folder.PossibleContent);
            }

            var properties        = props;
            var configConstructor = new ConfigConstructor
            {
                currentConfig       = config,
                availableAttributes = properties
            };

            ParameterizedThreadStart pts = new ParameterizedThreadStart(ThreadStart);
            Thread t = new Thread(ThreadStart);

            t.SetApartmentState(ApartmentState.STA);
            t.Start(configConstructor);
            t.Join();
            ((OwnedItem)item).SaveConfig(config);
            return(item);
        }
Example #4
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            if (objectToExecuteOn is TCFolder)
            {
                AddExecutionEntries(objectToExecuteOn as TCFolder);
            }

            if (objectToExecuteOn is ExecutionEntryFolder)
            {
                AddExecutionEntries(objectToExecuteOn as ExecutionEntryFolder);
            }

            if (objectToExecuteOn is ExecutionList)
            {
                AddExecutionEntries(objectToExecuteOn as ExecutionList);
            }
            TFSConnector tfs = new TFSConnector();
            foreach (ExecutionEntry ee in entries)
            {
                if (IsInteger(ee.ActualLog.ChangeRequestId))
                {
                    DefectResult dr = tfs.GetDefect(ee.ActualLog.ChangeRequestId);
                    ee.ActualLog.ChangeRequestState = dr.status;
                }
            }
            tfs.GetTFSDefectsWithToscaDefects();
            tfs.DisposeTFS();
            return null;
        }
        //static HttpClient client = new HttpClient();

        public override void Execute(TCAddOnTaskContext context)
        {
            //context.ShowMessageBox("Test Execute", "You clicked on a menu item.");
            RunAsync().Wait();
            Console.ReadLine();
            context.ShowMessageBox("Test Result", "Successfully Created Issue");
        }
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            NeoLoadSettings.WriteSettingsToUserFile("WEB");
            var exec = (objectToExecuteOn as ExecutionEntry).Run();

            NeoLoadSettings.DeleteUserFile();
            return(exec);
        }
Example #7
0
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;
     TFSConnector tfs = new TFSConnector();
     DefectResult dr = tfs.GetDefect(ee.ActualLog.ChangeRequestId);
     tfs.DisposeTFS();
     if (!String.IsNullOrEmpty(dr.status))
     {
         ee.ActualLog.Comment = dr.status;
     }
     return null;
 }
Example #8
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            // Create custom properties on Requirements and RequirementSets.
            // This is to be used to search when updating or knowing which ones have been created by this addon.
            ToscaHelpers.CreateCustomProperties("Requirement", Global.JiraTicket);
            ToscaHelpers.CreateCustomProperties("Requirement", Global.JiraLastSyncedAttributeName);
            ToscaHelpers.CreateCustomProperties("Requirement", Global.JiraSyncStateAttributeName);

            ToscaHelpers.CreateIssuesProperties("Issue", Global.JiraTicket);

            return(null);
        }
Example #9
0
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;
     int bugid = 0;
     Int32.TryParse(ee.ActualLog.ChangeRequestId, out bugid);
     if (bugid > 0)
     {
         TFSConnector tfsc = new TFSConnector();
         Process.Start(tfsc.GetWorkItemUrl(bugid).ToString());
     }
     return null;
 }
        public override TCObject Execute(List<TCObject> objs, TCAddOnTaskContext taskContext)
        {
            try
            {
                TestSheet ts = (TestSheet)objs.First().OwningObject;
                List<string> selectedAttribs = new List<string>();
                foreach (TCObject obj in objs)
                {
                    selectedAttribs.Add(obj.UniqueId);
                }

                foreach (TDInstance inst in ts.Instances.Items)
                {

                    string instName = "";
                    foreach (TDInstanceValue instValue in inst.Values)
                    {
                        if (selectedAttribs.Contains(instValue.Element.UniqueId))
                        {
                            if ((instValue.ValueInstance == null) || (instValue.ValueInstance.Character != TDCharacterE.StraightThrough))
                            {
                                if (string.IsNullOrWhiteSpace(instName))
                                {
                                    instName = string.Format("{0}", Settings.Default.TSRenameSplit);
                                }
                                else
                                {
                                    instName += string.Format("{0}", Settings.Default.TSRenameAnd);
                                }
                                instName += string.Format("{0}{1}{2}",
                                    instValue.Element.Name,
                                    Settings.Default.TSRenameEquals,
                                    instValue.ValueInstance == null ? instValue.Value : instValue.ValueInstance.Name);
                            }
                        }
                    }

                    inst.Name = string.Format("{0} {1} {2}", Settings.Default.TSRenamePrefix, ts.Name, instName).Trim();
                    inst.EnsureUniqueName();
                }
            }
            catch (Exception e)
            {
                taskContext.ShowErrorMessage("Well, this is embarrassing",
                    string.Format("An unhandled exception has occured."
                    + Environment.NewLine + Environment.NewLine + "{0}", e.ToString()));
            }

            return null;
        }
Example #11
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            DBScanWindow form = new DBScanWindow();
            form.ShowDialog();
            // If the user has not selected anyting
            if (form.XModule == null)
                return null;

            XModuleEntity xme = form.XModule;

            TCFolder folder = objectToExecuteOn as TCFolder;
            XModule xmodule = folder.CreateXModule();
            xmodule.Name = xme.Name;

            XParam engine = xmodule.CreateConfigurationParam();
            engine.Name = "Engine";
            engine.Value = "Engine";

            XParam set = xmodule.CreateConfigurationParam();
            set.Name = "SpecialExecutionTask";
            set.Value = "CompareDB";

            XParam connString = xmodule.CreateConfigurationParam();
            connString.Name = "ConnectionString";
            connString.Value = xme.ConnectionString;

            XParam tableName = xmodule.CreateConfigurationParam();
            tableName.Name = "TableName";
            tableName.Value = xme.Name;

            XParam orderAttrib = xmodule.CreateConfigurationParam();
            orderAttrib.Name = "OrderAttribute";
            orderAttrib.Value = xme.OrderAttribute;

            foreach (string item in xme.Attributes)
            {
                XModuleAttribute xma = xmodule.CreateModuleAttribute();
                xma.Name = item;
                xma.DefaultActionMode = XTestStepActionMode.Verify;
                XParam p1 = xma.CreateConfigurationParam();
                p1.Name = "Parameter";
                p1.Value = "True";
                XParam p2 = xma.CreateConfigurationParam();
                p2.Name = "ExplicitName";
                p2.Value = "True";
            }
            return null;
        }
Example #12
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            ExecutionEntry ee = objectToExecuteOn as ExecutionEntry;
            int bugid = 0;
            Int32.TryParse(ee.ActualLog.ChangeRequestId, out bugid);
            if (bugid > 0)
            {
                //var IE = new SHDocVw.InternetExplorer();
                //object URL = DefectTrackerSettings.Default.TFSuri + DefectTrackerSettings.Default.TFSwebUri + bugid.ToString();
                //IE.Visible = true;
                //IE.Navigate2(ref URL);
                Process.Start(DefectTrackerSettings.Default.TFSuri + DefectTrackerSettings.Default.TFSwebUri + bugid.ToString());

            }
            return null;
        }
        public override void Execute(TCAddOnTaskContext context)
        {
            string workSpaceName        = TCAddOn.ActiveWorkspace.GetTCProject().Name;
            string ToscaProjectPath     = Environment.GetEnvironmentVariable("Tricentis_Projects");
            string ToscaWorkspaces      = ToscaProjectPath + "\\" + "Tosca_Workspaces";
            string currentWorkspacePath = ToscaWorkspaces + "\\" + workSpaceName + "\\" + workSpaceName + ".tws";

            string           home              = Environment.GetEnvironmentVariable("Tricentis_Home");
            string           fileToRun         = home + "\\" + "DllReplacementUtility.exe";
            string           initialDialogPath = "C:\\Tosca_Projects\\Tosca ToolKit";
            string           fileToReplace     = context.GetFilePath("upload dll file", true, initialDialogPath, true, "dll", false);
            ProcessStartInfo psi = new ProcessStartInfo();

            psi.FileName  = fileToRun;
            psi.Arguments = fileToReplace.Replace(' ', '?') + " " + currentWorkspacePath.Replace(' ', '?');
            Process.Start(psi);
        }
Example #14
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            var currentFolder = objectToExecuteOn as TCComponentFolder;

            var newWindowThread = new Thread(() =>
            {
                SynchronizationContext.SetSynchronizationContext(
                    new DispatcherSynchronizationContext(
                        Dispatcher.CurrentDispatcher));

                var preferencesWindow = new MainWindow();

                preferencesWindow.Closed += (s, e) =>
                                            Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                preferencesWindow.Show();
                Dispatcher.Run();
            });

            newWindowThread.SetApartmentState(ApartmentState.STA);
            newWindowThread.IsBackground = true;
            newWindowThread.Start();
            newWindowThread.Join();


            var operation = "TBoxClipboard";

            var newTestCaseFolder = currentFolder.CreateTestCasesFolder();
            var testCase          = newTestCaseFolder.CreateTestCase();

            testCase.Name = operation;
            var     query   = "->PROJECT->AllOwnedSubItems=>SUBPARTS: XModule[SetWizard ==\"" + operation + "\"]";
            XModule xModule = objectToExecuteOn.Search(query)[0] as XModule;

            var currentTestStep = testCase.CreateXTestStepFromXModule(xModule).TestStepValues;

            switch (operation)
            {
            case "TBoxClipboard":
                new Clipboard().setupTestSteps(currentTestStep);
                break;
            }

            return(null);
        }
Example #15
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            IEnumerable <XModule> modules = ((TCFolder)objectToExecuteOn).Search("=>SUBPARTS:XModule").OfType <XModule>();
            string engines = string.Empty;

            foreach (var item in modules)
            {
                var engineParam = item.XParams.Where(t => t.Name == "Engine").First();
                if (!engines.Contains(engineParam.Value))
                {
                    engines += (engineParam.Value + Environment.NewLine);
                }
            }

            taskContext.ShowMessageBox("Used Engines", engines);

            return(objectToExecuteOn);
        }
Example #16
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            List <string> credentialUrls = CredentialManager.Instance.Credentials.Select(x => x.BaseURL).ToList();
            string        result         = taskContext.GetStringSelection("Select the URL which you want to enter new credentials for:", credentialUrls);

            if (CredentialManager.Instance.Credentials.Any(x => x.BaseURL == result))
            {
                string username = taskContext.GetStringValue("Username: "******"Password: ", true);
                CredentialManager.Instance.StoreOrUpdateCredential(new Credential
                {
                    BaseURL  = result,
                    Username = username,
                    Password = password
                });
            }
            return(objectToExecuteOn);
        }
Example #17
0
        public override void Execute(TCAddOnTaskContext context)
        {
            StringBuilder summaryInfo        = new StringBuilder();
            TCProject     project            = TCAddOn.ActiveWorkspace.GetTCProject();
            List <string> totalTcObjectCount = new List <string>();

            totalTcObjectCount.Add(" Requirements: " + project.Search("=>SUBPARTS:Requirement").Count());
            totalTcObjectCount.Add(" TestSheet: " + project.Search("=>SUBPARTS:TestSheet").Count());
            totalTcObjectCount.Add(" XModule: " + project.Search("=>SUBPARTS:XModule").Count());
            totalTcObjectCount.Add(" TestCase: " + project.Search("=>SUBPARTS:TestCase").Count());
            totalTcObjectCount.Add(" ExecutionList: " + project.Search("=>SUBPARTS:ExecutionList").Count());

            foreach (var item in totalTcObjectCount)
            {
                summaryInfo.Append(item + Environment.NewLine);
            }

            context.ShowMessageBox($"Summary of {project.DisplayedName}", $"Count of Tosca objects at {DateTime.Now + Environment.NewLine + Environment.NewLine + summaryInfo}");
        }
Example #18
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            if (objectToExecuteOn is TCFolder)
            {
                AddExecutionEntries(objectToExecuteOn as TCFolder);
            }

            if (objectToExecuteOn is ExecutionEntryFolder)
            {
                AddExecutionEntries(objectToExecuteOn as ExecutionEntryFolder);
            }

            if (objectToExecuteOn is ExecutionList)
            {
                AddExecutionEntries(objectToExecuteOn as ExecutionList);
            }
            TFSConnector tfs = new TFSConnector();
            List<Defect> TFSDefects = tfs.GetTFSDefectsWithToscaDefects();
            foreach (ExecutionEntry ee in entries)
            {
                if (IsInteger(ee.ActualLog.ChangeRequestId))
                {
                    DefectResult dr = tfs.GetDefect(ee.ActualLog.ChangeRequestId);
                    ee.ActualLog.ChangeRequestState = dr.status;
                }
                else
                {
                    Defect defect = TFSDefects.Find(d => d.uniqueid == ee.UniqueId);
                    if (defect != null)
                    {
                        ee.ActualLog.ChangeRequestState = defect.status;
                        ee.ActualLog.ChangeRequestId = defect.id.ToString();
                    }
                }
            }

            tfs.DisposeTFS();
            return null;
        }
Example #19
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            //var currentSetting=Config.ReadConfig();

            var folder           = objectToExecuteOn as TCFolder;
            var allHtmlDocuments = new Collection <Tuple <string, string> >();
            var scrapper         = new Scrapper();

            var newWindowThread = new Thread(() =>
            {
                SynchronizationContext.SetSynchronizationContext(
                    new DispatcherSynchronizationContext(
                        Dispatcher.CurrentDispatcher));

                var preferencesWindow = new WpfApplication1.MainWindow();

                preferencesWindow.Closed += (s, e) =>
                                            Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                preferencesWindow.Show();
                Dispatcher.Run();
            });

            newWindowThread.SetApartmentState(ApartmentState.STA);
            newWindowThread.IsBackground = true;
            newWindowThread.Start();

            const int currentPercent = 0;

            taskContext.ShowProgressInfo(100, currentPercent + 5, "Enter Domain");

            //var baseUrl = new Uri(taskContext.GetStringValue("Please enter a domain adress", false));
            //var mainData = GetHtml(baseUrl);

            GetHtml(new Uri("http://www.toscatrial.com/sampleapp/VehicleData.html"), folder);

            taskContext.ShowProgressInfo(100, 100, "Finishing");
            return(null);
        }
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            List <TCObject> modules     = (objectToExecuteOn as TCFolder).Search("=>SUBPARTS:XModule");
            List <string>   engineNames = new List <string>();
            List <string>   moduleNames = new List <string>();
            string          engineInfo  = string.Empty;

            foreach (XModule module in modules)
            {
                IEnumerable <XParam> parms = (module as XModule).XParams;
                foreach (XParam parm in parms)
                {
                    if (parm.Name.Equals("Engine"))
                    {
                        if (!engineNames.Contains(parm.Value))
                        {
                            engineNames.Add(parm.Value);
                            moduleNames.Add(string.Empty);
                        }
                        moduleNames[engineNames.IndexOf(parm.Value)]
                            = moduleNames[engineNames.IndexOf(parm.Value)] + "      " + module.Name + Environment.NewLine;
                        break;
                    }
                }
            }
            foreach (string engine in engineNames)
            {
                engineInfo = engineInfo +
                             "Engine " + engine + " in Modules: "
                             + Environment.NewLine
                             + moduleNames[engineNames.IndexOf(engine)]
                             + Environment.NewLine;
            }
            taskContext.ShowMessageBox("All Engines in Module Folder " + objectToExecuteOn.DisplayedName, engineInfo);
            return(objectToExecuteOn);
        }
Example #21
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            TCFolder            f           = (TCFolder)objectToExecuteOn;
            IEnumerable <Issue> childIssues = f.Search("->SUBPARTS:Issue").Cast <Issue>();

            var config = f.GetJiraConfig();

            if (config == null)
            {
                string url     = taskContext.GetStringValue("Jira Instance URL: ", false);
                string project = taskContext.GetStringValue("Jira Project Key: ", false);
                config = new JiraConfig {
                    baseURL = url, projectKey = project, fieldMaps = new List <FieldMap>()
                };
                f.SaveConfig(config);
            }
            string username, password;

            if (CredentialManager.Instance.Credentials.Any(x => x.BaseURL == config.baseURL))
            {
                Credential credential = CredentialManager.Instance.Credentials.First(x => x.BaseURL == config.baseURL);
                username = credential.Username;
                password = credential.Password;
            }
            else
            {
                username = taskContext.GetStringValue("Jira Username", false);
                password = taskContext.GetStringValue("Jira Password", true);
                CredentialManager.Instance.StoreOrUpdateCredential(new Credential
                {
                    BaseURL     = config.baseURL,
                    Description = "Created by Jira Config",
                    Username    = username,
                    Password    = password
                });
            }

            var jira         = new JiraService.Jira(config.baseURL, username, password);
            var issueService = jira.GetIssueService();

            foreach (var issue in childIssues)
            {
                string storedIssueKey = string.Empty;
                try
                {
                    storedIssueKey = issue.GetAttributeValue(Global.JiraTicket);
                }
                catch (Exception)
                {
                    throw new Exception("Please prepare project for integration (available from context menu at project level) and then try again");
                }
                if (!string.IsNullOrEmpty(storedIssueKey))
                {
                    var jiraIssue = issueService.GetAsync(storedIssueKey).Result;
                    issue.State = jiraIssue.fields.status.name;
                    issue.Name  = jiraIssue.fields.summary;
                }
                else //No existing Jira issue exists
                {
                    string description = issue.Description;
                    if (issue.Links.Any())
                    {
                        var executionLog = issue.Links.First().ExecutionTestCaseLog;
                        description = $"TEST: {executionLog.Name}\r\n{executionLog.AggregatedDescription}";
                    }
                    var newIssue = new JiraService.Issue.Issue
                    {
                        fields = new JiraService.Issue.IssueFields
                        {
                            summary     = issue.Name,
                            description = description,
                            //Create other fields here
                            project = new JiraService.Issue.Field.ProjectField {
                                key = config.projectKey
                            },
                            issuetype = new JiraService.Issue.Field.IssueTypeField {
                                name = "Bug"
                            }
                        }
                    };
                    foreach (var defaultValue in config.defaultValues)
                    {
                        newIssue.SetValueByPath(defaultValue.jiraJsonPath, defaultValue.defaultValue);
                    }
                    JiraService.Issue.Issue createdIssue = issueService.CreateAsync(newIssue).Result;
                    createdIssue = issueService.GetAsync(createdIssue.key).Result; //The created issue only contains a shell, no fields
                    issue.SetAttibuteValue(Global.JiraTicket, createdIssue.key);
                    issue.State = createdIssue.fields.status.name;
                }
            }
            return(objectToExecuteOn);
        }
Example #22
0
 public override void Execute(TCAddOnTaskContext context)
 {
     context.ShowMessageBox("Configuration", "You clicked on Configuration menu item.");
 }
Example #23
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;
        }
Example #24
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;
        }
        public override TCObject Execute(TCObject obj, List <TCObject> dropObjects, bool copy, TCAddOnTaskContext context)
        {
            TCFolder folder = obj as TCFolder;
            TestCase tc     = folder.CreateTestCase();

            tc.Name = "AddOn Drag-drop Test Cases";
            foreach (TCObject objDrop in dropObjects)
            {
                TCFolder        moduleFolder = objDrop as TCFolder;
                List <TCObject> modules      = moduleFolder.Search("=>SUBPARTS:XModule");
                tc.CreateXTestStepFromXModule(modules);
            }
            return(null);
        }
Example #26
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            //ITestDataHandler testDataHandler = new TestDataHandler.ToscaTestDataHandler(objectToExecuteOn);
            //AssistantMain assistant = new AssistantMain(testDataHandler);
            //assistant.StartMainWindow();


            //string toscahome = Path.GetFullPath(Environment.GetEnvironmentVariable("TRICENTIS_HOME"));

            System.Diagnostics.Process.Start("c:\\Temp\\ToscaAssistant.exe");


            var currentTescase = objectToExecuteOn as TestCase;
            var folder         = objectToExecuteOn as TCFolder;

            Thread.Sleep(5000);

            if (folder != null && folder.Name == "Modules")
            {
                XModule xModuleHome    = folder.CreateXModule();
                XModule xModuleManuals = folder.CreateXModule();

                xModuleHome.Name    = "Home";
                xModuleManuals.Name = "Manuals";

                return(null);
            }


            var     query   = "->PROJECT->AllOwnedSubItems=>SUBPARTS: XModule[SetWizard == \"File\"]";
            XModule xModule = objectToExecuteOn.Search(query)[0] as XModule;

            var currentTestStep = currentTescase.CreateXTestStepFromXModule(xModule);

            foreach (var testValue in currentTestStep.TestStepValues)
            {
                if (testValue.Name == "Directory")
                {
                    testValue.Value = "C:\\GIG";
                }


                if (testValue.Name == "File")
                {
                    testValue.Value = "createdFile.txt";
                }


                if (testValue.Name == "Text")
                {
                    testValue.Value = "Usability";
                }
            }

            foreach (var attribute in xModule.Attributes)
            {
                if (attribute.Name == "Encoding")
                {
                    XTestStepValue testStepValue = currentTestStep.CreateXTestStepValue(attribute);
                    testStepValue.Value = "UTF-8";
                }

                if (attribute.Name == "Overwrite")
                {
                    XTestStepValue testStepValue = currentTestStep.CreateXTestStepValue(attribute);
                    testStepValue.Value = "True";
                }
            }



            return(null);
        }
Example #27
0
        //static HttpClient client = new HttpClient();

        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            taskContext.ShowMessageBox("Attention", "Executed selected Item");
            RunAsync(objectToExecuteOn).Wait();
            return(null);
        }
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     taskContext.ShowMessageBox("Attention", String.Format("This entyr will be run via an AddOnTask: CWD: {0}", Environment.CurrentDirectory));
     (objectToExecuteOn as ExecutionEntry).Run();
     return(null);
 }
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     List<TCObject> objs = new List<TCObject>();
     objs.Add(objectToExecuteOn);
     return Execute(objs, taskContext);
 }
        public override TCObject Execute(TCObject obj, List <TCObject> dropObjects, bool copy, TCAddOnTaskContext context)
        {
            TCFolder folder   = (TCFolder)obj;
            TestCase testCase = folder.CreateTestCase();

            testCase.Name = "Drop Task AddOn";
            testCase.EnsureUniqueName();

            foreach (var objDrop in dropObjects)
            {
                TCFolder moduleFolder = objDrop as TCFolder;
                if (moduleFolder == null)
                {
                    continue;
                }
                List <TCObject> modules = moduleFolder.Search("=>SUBPARTS:XModule");
                testCase.CreateXTestStepFromXModule(modules);
            }

            return(null);
        }
Example #31
0
 public override void Execute(TCAddOnTaskContext context)
 {
     context.ShowMessageBox("Ribbon", "You clicked my ribbon item");
 }
Example #32
0
        //static HttpClient client = new HttpClient();

        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            taskContext.ShowMessageBox("Attention", "This entry will be run via an AddOnTask");
            RunAsync(objectToExecuteOn).Wait();
            return(null);
        }
Example #33
0
        /// <summary>
        /// This method handles the migration of Manual TestCase
        /// </summary>
        /// <param name="filePath">File Path of the ManualTestCase Excel sheet.</param>
        public void ProcessManualTestCaseFile(string filePath, TCAddOnTaskContext taskContext)
        {
            //ClosedXML has been used here to read the excel files. The library can be found in Tosca Installation Directory at '%TRICENTIS_HOME%\ToscaCommander'.
            //Alternatively, Microsoft.Office.Interop.Excel library or other third-party library can also be used.
            XLWorkbook workBook = new XLWorkbook(filePath);

            int workSheetNumber = 0;

            foreach (IXLWorksheet sheet in workBook.Worksheets)
            {
                workSheetNumber++;
                // track worksheet number
                taskContext.ShowProgressInfo(workBook.Worksheets.Count, workSheetNumber, "Process worksheet: " + sheet.Name);

                IXLRange usedRange           = sheet.RangeUsed();
                int      testCaseFolderId    = 0;
                int      testCaseId          = 0;
                int      testStepId          = 0;
                string   testFolderName      = "not resolved";
                string   testCaseName        = "not resolved";
                string   testCaseDescription = "not resolved";
                string   testStepName        = "not resolved";

                // exported hp sheet will start in row = 5
                // example in row = 5
                // properties in row = 4

                // we only have to import "Import_Tests_QC"
                if (sheet.Name.Equals("Import_Tests_QC") || (workBook.Worksheets.Count == 1))
                {
                    for (int row = 1; row <= usedRange.RowCount(); row++)
                    {
                        //taskContext.ShowProgressInfo(usedRange.RowCount(), row, "Processed rows (Max: " + usedRange.RowCount() + ")");

                        // exported hp sheet has data starting at column = 2
                        for (int column = -5; column <= usedRange.ColumnCount(); column++)
                        {
                            string cellValue = usedRange.Row(row).Cell(column).Value.ToString();
                            //taskContext.ShowStatusInfo("Actual cell (Max: " + usedRange.ColumnCount() + ")" + cellValue + "( with subject: " + usedRange.Row(3).Cell(column).Value.ToString() + ")");
                            if (!string.IsNullOrEmpty(cellValue))
                            {
                                switch (usedRange.Row(3).Cell(column).Value.ToString())
                                {
                                case "Subject":
                                    if (testFolderName == "not resolved" || !testFolderName.Equals(cellValue))
                                    {
                                        testFolderName = cellValue.Trim();
                                        //Creates TestFolder
                                        testCaseFolderId = Builder.CreateFolder(testFolderName, FolderType.TestCases, Definition.TestCasesFolderId);
                                    }
                                    break;

                                case "Test Name":
                                    if (!testCaseName.Equals(cellValue))
                                    {
                                        testCaseName = cellValue.Trim();
                                        //Creates TestCase
                                        testCaseId = Builder.CreateTestCase(testCaseName, testCaseDescription, testCaseFolderId);
                                    }
                                    break;

                                case "Test Description":
                                    testCaseDescription = cellValue.Trim();
                                    break;

                                case "Step Name":
                                    testStepName = cellValue.Trim();
                                    //Creates ManualTestStep
                                    testStepId = Builder.CreateManualTestStep(testStepName, testCaseId, null);
                                    break;

                                case "Step Description":
                                    //Creates ManualTestStepValue with ActionMode as Input
                                    Builder.CreateManualTestStepValue(cellValue, testStepId, "DATA", ActionMode.Input.ToString(), null);
                                    break;

                                case "Expected result":
                                    //Creates ManualTestStepValue with ActionMode as Verify
                                    Builder.CreateManualTestStepValue(cellValue, testStepId, "", ActionMode.Verify.ToString(), null);
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    taskContext.ShowStatusInfo("Not in scope: " + sheet.Name);
                }
            }
        }
Example #34
0
        public override TCObject Execute(TCObject requirementSet, TCAddOnTaskContext taskContext)
        {
            RequirementSet rs     = (RequirementSet)requirementSet;
            JiraConfig     config = rs.GetJiraConfig();

            #region Setup
            if (config == null)
            {
                string url      = taskContext.GetStringValue("Jira Instance URL: ", false);
                string jqlValue = taskContext.GetStringValue("JQL Filter for requirements: ", false);
                config = new JiraConfig
                {
                    baseURL   = url,
                    jqlFilter = jqlValue,
                    fieldMaps = new List <FieldMap>()
                    {
                        new FieldMap {
                            direction = JiraService.Configuration.Direction.jira_to_tosca, jiraJsonPath = "$.fields.summary", toscaField = "Name"
                        }
                    }
                };
                rs.SaveConfig(config);
            }
            string username, password;
            if (CredentialManager.Instance.Credentials.Any(x => x.BaseURL == config.baseURL))
            {
                Credential credential = CredentialManager.Instance.Credentials.First(x => x.BaseURL == config.baseURL);
                username = credential.Username;
                password = credential.Password;
            }
            else
            {
                username = taskContext.GetStringValue("Jira Username", false);
                password = taskContext.GetStringValue("Jira Password", true);
                CredentialManager.Instance.StoreOrUpdateCredential(new Credential
                {
                    BaseURL     = config.baseURL,
                    Description = "Created by Jira Config",
                    Username    = username,
                    Password    = password
                });
            }
            #endregion

            var    jira         = new JiraService.Jira(config.baseURL, username, password);
            var    issueService = jira.GetIssueService();
            String startTime    = DateTime.Now.ToString("yyyyMMddHHmmss");
            string jql          = config.jqlFilter;
            JiraService.Issue.Issue[]        issues    = null;
            Task <JiraService.Issue.Issue[]> issueTask = null;
            try
            {
                issueTask = issueService.SearchAsync(jql);
                while (!issueTask.IsCompleted)
                {
                    taskContext.ShowStatusInfo($"Gettign issues for JQL: {jql}");
                    System.Threading.Thread.Sleep(100);
                }
                //order the issues so that subtasks are not created before parent tasks
                issues = issueTask.Result.OrderBy(x => x.fields.project.name).ThenBy(x => x.id).ToArray();
                taskContext.ShowStatusInfo("Creating Requirements");
            }
            catch (Exception e)
            {
                string err = e.Message;
                if (e.InnerException != null)
                {
                    err += "\r\n" + e.InnerException.Message;
                }
                taskContext.ShowErrorMessage($"Error synchronising", err);
                taskContext.ShowStatusInfo($"Error synchronising: {err}");
                return(requirementSet);
            }
            HashSet <string> updatedItems = new HashSet <string>();
            if (issues != null)
            {
                foreach (var issue in issues)
                {
                    var req = CreateOrUpdateRequirement(rs, config, issue);
                    updatedItems.Add(req.UniqueId);
                }

                // Prompt status
                taskContext.ShowMessageBox("Jira Sync", issues.Length.ToString() + " requirements have been synchronised.");
            }
            return(null);
        }
Example #35
0
 public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
 {
     BackupProject.CreateBackup(objectToExecuteOn);
     DoImport(objectToExecuteOn);
     return(null);
 }
Example #36
0
        public override TCObject Execute(TCObject objectToExecuteOn, TCAddOnTaskContext taskContext)
        {
            TCFolder            f           = (TCFolder)objectToExecuteOn;
            IEnumerable <Issue> childIssues = f.Search("->SUBPARTS:Issue").Cast <Issue>();

            var config = f.GetJiraConfig();

            if (config == null)
            {
                string url     = taskContext.GetStringValue("Jira Instance URL: ", false);
                string project = taskContext.GetStringValue("Jira Project Key: ", false);
                config = new JiraConfig {
                    baseURL = url, projectKey = project, fieldMaps = new List <FieldMap>()
                };
                f.SaveConfig(config);
            }
            string username, password;

            if (CredentialManager.Instance.Credentials.Any(x => x.BaseURL == config.baseURL))
            {
                Credential credential = CredentialManager.Instance.Credentials.First(x => x.BaseURL == config.baseURL);
                username = credential.Username;
                password = credential.Password;
            }
            else
            {
                username = taskContext.GetStringValue("Jira Username", false);
                password = taskContext.GetStringValue("Jira Password", true);
                CredentialManager.Instance.StoreOrUpdateCredential(new Credential
                {
                    BaseURL     = config.baseURL,
                    Description = "Created by Jira Config",
                    Username    = username,
                    Password    = password
                });
            }

            var jira         = new JiraService.Jira(config.baseURL, username, password);
            var issueService = jira.GetIssueService();

            foreach (var issue in childIssues)
            {
                string storedIssueKey = string.Empty;
                try
                {
                    storedIssueKey = issue.GetAttributeValue(Global.JiraTicket);
                }
                catch (Exception)
                {
                    throw new Exception("Please prepare project for integration (available from context menu at project level) and then try again");
                }
                if (!string.IsNullOrEmpty(storedIssueKey))
                {
                    var jiraIssue = issueService.GetAsync(storedIssueKey).Result;
                    issue.State = jiraIssue.fields.status.name;
                    issue.Name  = jiraIssue.fields.summary;
                }
                else //No existing Jira issue exists
                {
                    string description = issue.Description;
                    if (issue.Links.Any())
                    {
                        try
                        {
                            var    executionLog         = issue.Links.First().ExecutionTestCaseLog;
                            string executionTableHeader = $"||Step||Result||Description||Duration(sec)";
                            string executionTable       = null;
                            foreach (ExecutionXTestStepLog logEntry in executionLog.ExecutionSubLogs)
                            {
                                string stepDesc = logEntry.AggregatedDescription;

                                if (logEntry.TestStepValueLogsInRightOrder.Count() > 0)
                                {
                                    stepDesc = null;
                                    foreach (var stepVal in logEntry.TestStepValueLogsInRightOrder)
                                    {
                                        string act = $"{(stepVal.Result == ExecutionResult.Passed ? "(/)" : "(x)")} - {stepVal.DisplayedName} - {stepVal.LogInfo}";
                                        if (stepDesc == null)
                                        {
                                            stepDesc = act;
                                        }
                                        else
                                        {
                                            stepDesc = stepDesc + "\r\n" + act;
                                        }
                                    }
                                }
                                stepDesc = stepDesc.Replace('{', ' ').Replace('}', ' ').Replace('|', ' ').Trim();
                                string entry = $"|{logEntry.DisplayedName} |{(logEntry.Result == ExecutionResult.Passed ? "{color:#14892c}" : "{color:#d04437}") + logEntry.Result + "{color}"} |{stepDesc}|{Math.Round(logEntry.Duration / 1000,2)}s|";
                                if (executionTable == null)
                                {
                                    executionTable = entry;
                                }
                                else
                                {
                                    executionTable += "\r\n" + entry;
                                }
                            }
                            description = $"*TEST*: {executionLog.Name}\r\n*Description*:\r\n{executionTableHeader}\r\n{executionTable}";
                        }
                        catch (Exception)
                        {
                            description = issue.Description;
                        }
                    }
                    var newIssue = new JiraService.Issue.Issue
                    {
                        fields = new JiraService.Issue.IssueFields
                        {
                            summary     = issue.Name,
                            description = description,
                            //Create other fields here
                            project = new JiraService.Issue.Field.ProjectField {
                                key = config.projectKey
                            },
                            issuetype = new JiraService.Issue.Field.IssueTypeField {
                                name = "Bug"
                            }
                        }
                    };
                    foreach (var defaultValue in config.defaultValues)
                    {
                        newIssue.SetValueByPath(defaultValue.jiraJsonPath, defaultValue.defaultValue);
                    }
                    JiraService.Issue.Issue createdIssue = issueService.CreateAsync(newIssue).Result;
                    createdIssue = issueService.GetAsync(createdIssue.key).Result; //The created issue only contains a shell, no fields
                    issue.SetAttibuteValue(Global.JiraTicket, createdIssue.key);
                    issue.State = createdIssue.fields.status.name;
                }
            }
            return(objectToExecuteOn);
        }