private List<TestStep> CreateTestStepsIds(TestActionCollection testActionCollection, int testCaseId, string environment)
        {
            var result = new List<TestStep>();

            int i = 1;
            foreach (var action in testActionCollection)
            {
                if (TestConductor.IsSharedStep(action))
                {
                    var sharedStepRef = action as ISharedStepReference;
                    // ReSharper disable once PossibleNullReferenceException
                    var sharedStep = sharedStepRef.FindSharedStep();
                    foreach (var sharedStepAction in sharedStep.Actions)
                    {
                        result.Add(TestStep.CreateSharedStep(sharedStepRef.SharedStepId, sharedStepAction.Id, ((ITestStep)sharedStepAction).Title.ToString(), environment, sharedStep.Title));
                    }
                }
                else
                {
                    result.Add(TestStep.CreateStep(testCaseId, action.Id, ((ITestStep)action).Title.ToString(), i++, ((ITestStep)action).ExpectedResult.ToString(), environment));
                }
            }

            return result;
        }
示例#2
0
        /// <summary>
        /// Заполняет Excel таблицу данными по шагам тестового случая.
        /// </summary>
        /// <param name="testActions">Шаги теста.</param>
        private void BySteps(TestActionCollection testActions)
        {
            int stepId = 1;

            foreach (var stestStep in testActions)
            {
                ITestStep testStep = stestStep as ITestStep;
                if (testStep != null)
                {
                    xlWorkSheet.Cells[row, 3] = stepId.ToString() + @". " + testStep.Title.ToPlainText();
                    xlWorkSheet.Cells[row, 4] = testStep.ExpectedResult.ToPlainText();
                    stepId++;
                    row++;
                }
                else
                {
                    //расшаренный шаг
                    ISharedStep testStepS = stestStep as ISharedStep;
                    if (testStepS != null)
                    {
                        xlWorkSheet.Cells[row, 3] = testStepS.Title.ToString() + @". " + testStep.Title.ToPlainText();
                        stepId++;
                        row++;
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Заполняет Excel таблицу по тестовому случаю.
        /// </summary>
        /// <param name="testCase">Тестовый случай.</param>
        private void ByTest(ITestCase testCase)
        {
            xlWorkSheet.Cells[row, 1] = testNumber.ToString() + @".";
            xlWorkSheet.Cells[row, 2] = testCase.Title;

            string upperBound  = "a";
            string lowerBound  = "a";
            string upperBound2 = "b";
            string lowerBound2 = "b";

            upperBound  += row;
            upperBound2 += row;

            TestActionCollection testActions = testCase.Actions;

            BySteps(testActions);

            lowerBound  += (row - 1);
            lowerBound2 += (row - 1);

            xlWorkSheet.get_Range(upperBound, lowerBound).Merge(false);

            chartRange = xlWorkSheet.get_Range(upperBound, lowerBound);
            chartRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
            chartRange.VerticalAlignment   = 1;

            xlWorkSheet.get_Range(upperBound2, lowerBound2).Merge(false);
            chartRange = xlWorkSheet.get_Range(upperBound2, lowerBound2);
            chartRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
            chartRange.VerticalAlignment   = 1;
            testNumber++;
        }
示例#4
0
        /// <summary>
        /// Generates all the step data from a set of TFS test actions
        /// </summary>
        /// <param name="actions">Collection of steps from the tc.</param>
        /// <param name="id">TFS tc id for displaying a helpful error message.</param>
        /// <param name="site">Required for pushing embedded steps to matching Site.</param>
        /// <returns></returns>
        public List <TestStepData> GetStepData(TestActionCollection actions, int id, Site site)
        {
            List <TestStepData> stepList = new List <TestStepData>();

            foreach (ITestAction action in actions)
            {
                if (action is ISharedStepReference)
                {
                    // if action is a shared step, ensure it is pushed to RF
                    ISharedStepReference sharedRef = action as ISharedStepReference;
                    var failures = this.Operations.CopyTestToRainforest(new List <int> {
                        sharedRef.SharedStepId
                    }, null, site).Result;

                    // get the RFID for the TFS SharedStep
                    int?rfId = this.GetRFID(sharedRef.SharedStepId);
                    if (rfId == null)
                    {
                        throw new Core.ServiceException(Core.Error.TFSSharedTestDoesNotExist, sharedRef.SharedStepId.ToString());
                    }
                    // add to list
                    stepList.Add(new TestStepData(sharedRef.SharedStepId, rfId, null, null));
                }
                else if (action is ITestStep)
                {
                    // action is a normal step, not shared
                    ITestStep step = action as ITestStep;
                    stepList.Add(new TestStepData(null, null, Regex.Replace(step.Title, @"<[^>]*>", ""), Regex.Replace(step.ExpectedResult, @"<[^>]*>", "")));

                    // check for empty step
                    if (stepList.Last().Title.Trim().Equals(""))
                    {
                        stepList.RemoveAt(stepList.Count - 1);
                        continue;
                    }

                    var lastExpectedResult = stepList.Last().ExpectedResult.Trim();
                    // check for empty expected result
                    if (lastExpectedResult.Equals(""))
                    {
                        throw new Core.ServiceException(Core.Error.EmptyExpectedResult, id.ToString());
                    }
                    // check for a question mark on the expected result

                    if (lastExpectedResult.Trim().Last() != '?')
                    {
                        stepList.Last().ExpectedResult += '?';
                    }
                }
                else
                {
                    throw new Exception("TestCase action is unknown type.");
                }                                                                   // TOEX -> this case shouldn't be hit ever
            }
            return(stepList);
        }
示例#5
0
        //Copy all subTest suites from source root test suite to destination plan's root test suites.
        private void CopyTestCases(IStaticTestSuite sourcesuite, IStaticTestSuite destinationsuite)
        {
            ITestSuiteEntryCollection suiteentrys = sourcesuite.TestCases;

            foreach (ITestSuiteEntry testcase in suiteentrys)
            {
                try
                {   //check whether testcase exists in new work items(closed work items may not be created again).
                    if (!workItemMap.ContainsKey(testcase.TestCase.WorkItem.Id))
                    {
                        logger.Info("RK: could not find test case with id " + testcase.TestCase.WorkItem.Id);
                        continue;
                    }

                    int       newWorkItemID = (int)workItemMap[testcase.TestCase.WorkItem.Id];
                    ITestCase tc            = destinationproj.TestCases.Find(newWorkItemID);
                    destinationsuite.Entries.Add(tc);

                    bool updateTestCase = false;
                    TestActionCollection testActionCollection = tc.Actions;
                    foreach (var item in testActionCollection)
                    {
                        var sharedStepRef = item as ISharedStepReference;
                        if (sharedStepRef != null)
                        {
                            int newSharedStepId = (int)workItemMap[sharedStepRef.SharedStepId];
                            //GetNewSharedStepId(testCase.Id, sharedStepRef.SharedStepId);
                            if (0 != newSharedStepId)
                            {
                                sharedStepRef.SharedStepId = newSharedStepId;
                                updateTestCase             = true;
                            }
                            else
                            {
                                logger.Info("RK: could not find new shared step for " + sharedStepRef.SharedStepId);
                            }
                        }
                    }
                    if (updateTestCase)
                    {
                        logger.InfoFormat("Test case with Id: {0} updated", tc.Id);
                        tc.Save();
                    }
                    else
                    {
                        logger.Info("RK: Test case " + tc.Id + " saved.");
                        tc.Save();
                    }
                }
                catch (Exception)
                {
                    logger.Info("Error retrieving Test case  " + testcase.TestCase.WorkItem.Id + ": " + testcase.Title);
                }
            }
        }
示例#6
0
        private static ISharedStepReference[] GetSharedSteps(TestActionCollection actions)
        {
            var result = new List <ISharedStepReference>();

            foreach (ISharedStepReference step in actions)
            {
                result.Add(step);
            }

            return(result.ToArray());
        }
示例#7
0
        private void HandleSharedStep()
        {
            if (IsSharedStep(_currentStep))
            {
                _currentSharedStepsPointer = 0;
                _currentSharedStep         = (ISharedStepReference)_currentStep;
                ISharedStep          ss            = _currentSharedStep.FindSharedStep();
                TestActionCollection sharedActions = ss.Actions;
                _currentSharedTestStepResult = CreateSharedStepResult(_currentSharedStep) as ISharedStepResult;

                _currentSharedSteps.AddRange(sharedActions);
                _currentStep = _currentSharedSteps[_currentSharedStepsPointer++];
            }
        }
示例#8
0
        //Copy all subTest suites from source root test suite to destination plan's root test suites.
        private void CopyTestCases(IStaticTestSuite sourcesuite, IStaticTestSuite destinationsuite)
        {
            ITestSuiteEntryCollection suiteentrys = sourcesuite.TestCases;

            destinationsuite.Entries.RemoveCases(destinationsuite.Entries.OfType <ITestCase>());

            foreach (ITestSuiteEntry testcase in suiteentrys)
            {
                try
                {   //check whether testcase exists in new work items(closed work items may not be created again).
                    if (!WorkItemIdMap.Contains(testcase.TestCase.WorkItem.Id))
                    {
                        continue;
                    }

                    int       newWorkItemID = WorkItemIdMap[testcase.TestCase.WorkItem.Id];
                    ITestCase tc            = destinationproj.TestCases.Find(newWorkItemID);
                    destinationsuite.Entries.Add(tc);

                    bool updateTestCase = false;
                    TestActionCollection testActionCollection = tc.Actions;
                    foreach (var item in testActionCollection)
                    {
                        var sharedStepRef = item as ISharedStepReference;
                        if (sharedStepRef != null)
                        {
                            int newSharedStepId = (int)WorkItemIdMap[sharedStepRef.SharedStepId];
                            //GetNewSharedStepId(testCase.Id, sharedStepRef.SharedStepId);
                            if (0 != newSharedStepId)
                            {
                                sharedStepRef.SharedStepId = newSharedStepId;
                                updateTestCase             = true;
                            }
                        }
                    }
                    if (updateTestCase)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Test case with Id: {0} updated", tc.Id);
                        tc.Save();
                    }
                }
                catch (Exception)
                {
                    logger.Info("Error retrieving Test case  " + testcase.TestCase.WorkItem.Id + ": " + testcase.Title);
                }
            }
        }
示例#9
0
        //Copy all subTest suites from source root test suite to destination plan's root test suites.
        private void CopyTestCases(IStaticTestSuite sourcesuite, IStaticTestSuite destinationsuite)
        {
            ITestSuiteEntryCollection suiteentrys = sourcesuite.TestCases;

            foreach (ITestSuiteEntry testcase in suiteentrys)
            {
                try
                {   //check whether testcase exists in new work items(closed work items may not be created again).
                    if (!WorkItemMap.ContainsKey(testcase.TestCase.WorkItem.Id))
                    {
                        continue;
                    }

                    int       newWorkItemID = (int)WorkItemMap[testcase.TestCase.WorkItem.Id];
                    ITestCase tc            = targetTestMgmtProj.TestCases.Find(newWorkItemID);
                    destinationsuite.Entries.Add(tc);

                    bool updateTestCase = false;
                    TestActionCollection testActionCollection = tc.Actions;
                    foreach (var item in testActionCollection)
                    {
                        if (item is ISharedStepReference sharedStepRef)
                        {
                            int newSharedStepId = (int)WorkItemMap[sharedStepRef.SharedStepId];
                            //GetNewSharedStepId(testCase.Id, sharedStepRef.SharedStepId);
                            if (0 != newSharedStepId)
                            {
                                sharedStepRef.SharedStepId = newSharedStepId;
                                updateTestCase             = true;
                            }
                        }
                    }
                    if (updateTestCase)
                    {
                        Console.WriteLine();
                        Console.WriteLine($"Test case with Id: {tc.Id} updated");
                        tc.Save();
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine($"Error retrieving Test case {testcase.TestCase.WorkItem.Id}: {testcase.Title}");
                }
            }
        }
        private int GenerateTestCase(ITestSuiteEntry testCaseEntry, int startRow)
        {
            int currentRowNumber  = this.GenerateTestCaseHeader(startRow, testCaseEntry);
            int startingRowNumber = currentRowNumber;
            int stepNumber        = 1;

            foreach (ITestAction action in testCaseEntry.TestCase.Actions)
            {
                if (action is ISharedStepReference)
                {
                    ISharedStepReference isr           = (ISharedStepReference)action;
                    ISharedStep          ss            = isr.FindSharedStep();
                    TestActionCollection sharedActions = ss.Actions;

                    foreach (ITestAction sharedAction in sharedActions)
                    {
                        GenereateTestStepRow(currentRowNumber, stepNumber, (ITestStep)sharedAction);
                        stepNumber++;
                        currentRowNumber++;
                    }
                }
                else
                {
                    GenereateTestStepRow(currentRowNumber, stepNumber, (ITestStep)action);
                    stepNumber++;
                    currentRowNumber++;
                }
            }

            int endingRowNumber = currentRowNumber - 1;

            _range = _worksheet.get_Range("B" + startingRowNumber, (RefinementWindow.createComments ? "E" : "D") + endingRowNumber);
            DrawAllSolidBorders(_range, 0);

            return(currentRowNumber + 1);
        }
示例#11
0
        //Copy all subTest suites from source root test suite to destination plan's root test suites.
        private void CopyTestCases(IStaticTestSuite sourcesuite, IStaticTestSuite destinationsuite)
        {
            ITestSuiteEntryCollection suiteentrys = sourcesuite.TestCases;

            foreach (ITestSuiteEntry testcase in suiteentrys)
            {
                try
                {   //check whether testcase exists in new work items(closed work items may not be created again).
                    WorkItem  newWorkItem = null;
                    Hashtable fieldMap    = ListToTable((List <object>)workItemMap[testcase.TestCase.WorkItem.Type.Name]);
                    newWorkItem = new WorkItem(workItemTypes["Test Case"]);
                    foreach (Field field in testcase.TestCase.WorkItem.Fields)
                    {
                        if (field.Name.Contains("ID") || field.Name.Contains("Reason"))
                        {
                            continue;
                        }
                        if (field.Name == "Assigned To" || field.Name == "Activated By")
                        {
                            testcase.TestCase.WorkItem.Open();
                            testcase.TestCase.WorkItem.Fields[field.Name].Value = "*****@*****.**";
                        }
                        if (newWorkItem.Fields.Contains(field.Name) && newWorkItem.Fields[field.Name].IsEditable)
                        {
                            newWorkItem.Fields[field.Name].Value = field.Value;
                            if (field.Name == "Iteration Path" || field.Name == "Area Path" || field.Name == "Node Name" || field.Name == "Team Project")
                            {
                                try
                                {
                                    string itPath    = (string)field.Value;
                                    int    length    = sourceproj.TeamProjectName.Length;
                                    string itPathNew = destinationproj.TeamProjectName + itPath.Substring(length);
                                    newWorkItem.Fields[field.Name].Value = itPathNew;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                        //Add values to mapped fields
                        else if (fieldMap.ContainsKey(field.Name))
                        {
                            try
                            {
                                newWorkItem.Fields[(string)fieldMap[field.Name]].Value = field.Value;
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }
                        }
                    }
                    ArrayList array = newWorkItem.Validate();
                    foreach (Field item in array)
                    {
                        logger.Info(String.Format("Work item {0} Validation Error in field: {1}  : {2}", item.Name, newWorkItem.Fields[item.Name].Value));
                    }
                    if (array.Count == 0)
                    {
                        SaveAttachments(testcase.TestCase.WorkItem);
                        UploadAttachments(newWorkItem, testcase.TestCase.WorkItem);
                        newWorkItem.Save();
                        ITestCase tc = destinationproj.TestCases.Find(newWorkItem.Id);
                        destinationsuite.Entries.Add(tc);
                        TestActionCollection testActionCollection = testcase.TestCase.Actions;
                        foreach (var item in testActionCollection)
                        {
                            item.CopyToNewOwner(tc);
                        }
                        tc.Save();
                    }
                }
                catch (Exception ex)
                {
                    logger.Info("Error retrieving Test case  " + testcase.TestCase.WorkItem.Id + ": " + testcase.Title + ex.Message);
                }
            }
        }
示例#12
0
        /// <summary>
        /// Gets test cases
        /// </summary>
        public DataTable GetTestCases()
        {
            (new Logger())
            .SetMessage("Querying test cases.")
            .SetLoggingType(Logger.Type.Information)
            .Display();

            // create steps data table
            DataTable testCasesTable = new DataTable();

            testCasesTable.Columns.Add("ID", typeof(int));
            testCasesTable.Columns.Add("Title", typeof(string));
            testCasesTable.Columns.Add("Steps", typeof(string));

            // get the TFS test management server and query
            ITestManagementService     testManagementService = this.projectCollection.GetService <ITestManagementService>();
            ITestManagementTeamProject testProject           = testManagementService.GetTeamProject(this.projectName);
            ITestCaseHelper            testCaseHelper        = testProject.TestCases;
            IEnumerable <ITestCase>    tcc = testProject.TestCases.Query("SELECT * " +
                                                                         "FROM workitems " +
                                                                         "WHERE [System.TeamProject] = '" + this.projectName + "' " +
                                                                         "AND [System.WorkItemType] = 'Test Case'" +
                                                                         "AND [System.IterationPath] = '" + this.projectName + "\\" + (this.projectSubpath != null && this.projectSubpath != "" ? this.projectSubpath + "\\" : "") + this.iterationNumber + "'");

            // through all items that are test cases
            foreach (ITestCase testCase in tcc)
            {
                // get the work item data
                WorkItem workItem = testCase.Links.WorkItem;
                int      id       = workItem.Id;
                string   title    = workItem.Title;
                string   desc     = workItem.Description;
                string   steps    = "";

                // get collection of test actions
                TestActionCollection testActionCollection = testCase.Actions;
                int counter = 1;

                // iterate through all test actions
                for (int i = 0; i < testActionCollection.Count; i++)
                {
                    // get an action
                    var action = testCase.Actions[i];

                    // if not test step, ignore
                    if (!(action is ITestStep))
                    {
                        continue;
                    }
                    else
                    {
                        // get the test step
                        var    step       = action as ITestStep;
                        int    stepNumber = counter;
                        string stepTitle  = Utilities.StripHtmlContrived(step.Title, true);
                        string result     = Utilities.StripHtmlContrived(step.ExpectedResult, true);
                        steps += "Step #" + stepNumber + ": " + stepTitle + "\n";
                        if (result.Trim().Count() != 0)
                        {
                            steps += "Expected Result: " + result + "\n";
                        }
                        steps += "\n";
                        counter++;
                    }
                }

                // add to data table
                testCasesTable.Rows.Add(id, title, steps);
            }
            return(testCasesTable);
        }
示例#13
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            //DateTime startDateTime = DateTime.Now;
            flag6 = 1;

            if (txtFileName.Text != null || txtFileName.Text != "")
            {
                flag5 = 1;
            }
            if (txtSaveFolder.Text != null || txtSaveFolder.Text != "")
            {
                flag4 = 1;
            }
            //if (cbApplyDateFilter.Checked && (DateTime.Compare(dtpCompleteEnd.Value, dtpCompleteStart.Value) >= 0))
            //{
            //    flag6 = 1;
            //}
            //else if (!cbApplyDateFilter.Checked)
            //{
            //    flag6 = 1;
            //}
            //else
            //{
            //    flag6 = 0;
            //}

            if (flag1 == 1 && flag2 == 1 && flag3 == 1 && flag4 == 1 && flag5 == 1 && flag6 == 1)
            {
                this.Cursor             = Cursors.WaitCursor;
                btnExport.Enabled       = false;
                btnCancel.Enabled       = false;
                btnTeamProject.Enabled  = false;
                btnFolderBrowse.Enabled = false;
                comBoxTestPlan.Enabled  = false;
                comBoxTestSuite.Enabled = false;
                string filePath = string.Format(@"{0}\{1}.xlsx", txtSaveFolder.Text.Trim(), txtFileName.Text.Trim());

                Excel.Application xlApp;
                Excel.Workbook    xlWorkBook;
                Excel.Worksheet   xlWorkSheet;
                object            misValue = System.Reflection.Missing.Value;
                Excel.Range       chartRange;

                xlApp      = new Excel.Application();
                xlWorkBook = null;

                if (!File.Exists(filePath))
                {
                    xlWorkBook = xlApp.Workbooks.Add(misValue);
                    xlWorkBook.SaveAs(filePath);
                }

                xlWorkBook  = xlApp.Workbooks.Open(filePath);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.Add();
                string wsName = (comBoxTestSuite.Text.Length > 15) ? comBoxTestSuite.Text.Substring(0, 15) : comBoxTestSuite.Text;
                xlWorkSheet.Name = string.Concat(xlWorkSheet.Name.Substring(5), string.Format(" {0}-{1}", wsName, cmbRunType.Text));

                xlWorkSheet.Cells[1, 1] = "ID";
                //xlWorkSheet.Cells[1, 2] = "Pass %";
                // xlWorkSheet.Cells[1, 3] = "Fail %";
                // xlWorkSheet.Cells[1, 4] = "RunCount";
                // xlWorkSheet.Cells[1, 5] = "LatestResult";
                //  xlWorkSheet.Cells[1, 6] = "Run Date";
                // xlWorkSheet.Cells[1, 7] = "State";
                xlWorkSheet.Cells[1, 8]  = "Priority";
                xlWorkSheet.Cells[1, 9]  = "WI Type";
                xlWorkSheet.Cells[1, 10] = "Title";
                xlWorkSheet.Cells[1, 11] = "Action";
                xlWorkSheet.Cells[1, 12] = "Expected Result";
                //  xlWorkSheet.Cells[1, 13] = "Complexity";
                xlWorkSheet.Cells[1, 14] = "Tags";
                //  xlWorkSheet.Cells[1, 15] = "Area Path";
                //  xlWorkSheet.Cells[1, 16] = "Iteration Path";
                //  xlWorkSheet.Cells[1, 17] = "Module/Feature";

                (xlWorkSheet.Columns["A", Type.Missing]).ColumnWidth = 5;
                (xlWorkSheet.Columns["B", Type.Missing]).ColumnWidth = 5;
                (xlWorkSheet.Columns["C", Type.Missing]).ColumnWidth = 5;
                (xlWorkSheet.Columns["D", Type.Missing]).ColumnWidth = 8;
                (xlWorkSheet.Columns["E", Type.Missing]).ColumnWidth = 10;
                (xlWorkSheet.Columns["F", Type.Missing]).ColumnWidth = 12;
                (xlWorkSheet.Columns["G", Type.Missing]).ColumnWidth = 8;
                (xlWorkSheet.Columns["H", Type.Missing]).ColumnWidth = 6;
                (xlWorkSheet.Columns["I", Type.Missing]).ColumnWidth = 8;
                (xlWorkSheet.Columns["J", Type.Missing]).ColumnWidth = 40;
                (xlWorkSheet.Columns["K", Type.Missing]).ColumnWidth = 40;
                (xlWorkSheet.Columns["L", Type.Missing]).ColumnWidth = 40;
                (xlWorkSheet.Columns["M", Type.Missing]).ColumnWidth = 10;
                (xlWorkSheet.Columns["N", Type.Missing]).ColumnWidth = 30;
                (xlWorkSheet.Columns["O", Type.Missing]).ColumnWidth = 30;
                (xlWorkSheet.Columns["P", Type.Missing]).ColumnWidth = 30;
                (xlWorkSheet.Columns["Q", Type.Missing]).ColumnWidth = 20;


                int    row        = 2;
                int    col        = 1;
                string upperBound = "a";
                string lowerBound = "a";

                // cache tfs query results
                ITestRunHelper         allTestRuns        = null;
                IEnumerable <ITestRun> testRuns           = null;
                ITestCaseResultHelper  allTestCaseResults = null;

                try
                {
                    //Cache the testRuns
                    allTestRuns = _teamProject.TestRuns;

                    if (string.Compare(cmbRunType.Text.Trim(), "Manual") == 0)
                    {
                        testRuns = allTestRuns.Query("select TestRunID From TestRun where IsAutomated=0");
                    }
                    else if (string.Compare(cmbRunType.Text.Trim(), "Automated") == 0)
                    {
                        testRuns = allTestRuns.Query("select TestRunID From TestRun where IsAutomated=1");
                    }

                    //Cache testresults
                    allTestCaseResults = this._teamProject.TestResults;

                    foreach (ITestCase testCase in testCases)
                    {
                        upperBound = "a";
                        lowerBound = "a";
                        col        = 1;

                        // Get the test results
                        var testCaseResult = allTestCaseResults.ByTestId(testCase.Id).Where(b => b.Outcome == TestOutcome.Passed || b.Outcome == TestOutcome.Failed);

                        // apply date filter to the results
                        //if (cbApplyDateFilter.Checked)
                        //{
                        //    testCaseResult = testCaseResult.Where(t => DateTime.Compare(t.DateCompleted.Date, dtpCompleteStart.Value.Date) >= 0 && DateTime.Compare(t.DateCompleted.Date, dtpCompleteEnd.Value.Date) <= 0);
                        //}

                        // apply Run Type filter
                        if (string.Compare(cmbRunType.Text.Trim(), "All") != 0)
                        {
                            testCaseResult = testCaseResult.Where(a => testRuns.FirstOrDefault(b => b.Id == a.TestRunId) != null);
                        }

                        // order the output in decending order to get the latest record
                        testCaseResult = testCaseResult.OrderByDescending(t => t.DateCompleted);

                        if (testCaseResult.Count() > 0)
                        {
                            int   runCount  = testCaseResult.Count();
                            float passCount = testCaseResult.Where(p => p.Outcome == TestOutcome.Passed).Count();
                            float failCount = testCaseResult.Where(p => p.Outcome == TestOutcome.Failed).Count();

                            float passPercent = ((passCount / runCount) * 100);
                            float failPercent = ((failCount / runCount) * 100);

                            // xlWorkSheet.Cells[row, 4] = runCount;
                            //xlWorkSheet.Cells[row, 2] = passPercent.ToString("00.00");
                            // xlWorkSheet.Cells[row, 3] = failPercent.ToString("00.00");
                            // xlWorkSheet.Cells[row, 5] = testCaseResult.FirstOrDefault().Outcome.ToString();
                            // xlWorkSheet.Cells[row, 6] = testCaseResult.FirstOrDefault().DateCompleted.ToString();
                        }
                        else
                        {
                            xlWorkSheet.Cells[row, 5] = "Not Run";
                        }

                        xlWorkSheet.Cells[row, 1] = testCase.Id.ToString();
                        //xlWorkSheet.Cells[row, 7] = testCase.State.ToString();
                        xlWorkSheet.Cells[row, 8]  = testCase.Priority.ToString();
                        xlWorkSheet.Cells[row, 9]  = "Test Title";
                        xlWorkSheet.Cells[row, 10] = testCase.Title.ToString();
                        //xlWorkSheet.Cells[row, 13] = testCase.WorkItem.Fields["Complexity"].OriginalValue.ToString();
                        xlWorkSheet.Cells[row, 14] = testCase.WorkItem.Tags.ToString();
                        //   xlWorkSheet.Cells[row, 15] = testCase.Area.ToString();
                        //  xlWorkSheet.Cells[row, 16] = testCase.WorkItem.IterationPath.ToString();
                        //  xlWorkSheet.Cells[row, 17] = testCase.WorkItem.NodeName.ToString();

                        upperBound += row;

                        row++;
                        TestActionCollection testActions = testCase.Actions;
                        foreach (ITestAction testAction in testActions)
                        {
                            var    tstSharedStepRef  = testAction as ISharedStepReference;
                            string strStep           = string.Empty;
                            string strExpectedResult = string.Empty;

                            if (tstSharedStepRef != null)
                            {
                                ISharedStep tstSharedStep = tstSharedStepRef.FindSharedStep();
                                foreach (ITestAction tstSharedAction in tstSharedStep.Actions)
                                {
                                    ITestStep tstSharedTestStep = tstSharedAction as ITestStep;
                                    writeTestSteps(ref xlWorkSheet, tstSharedTestStep, ref row, ref col);
                                }
                            }
                            else
                            {
                                ITestStep tstSharedTestStep = testAction as ITestStep;
                                writeTestSteps(ref xlWorkSheet, tstSharedTestStep, ref row, ref col);
                            }
                        }
                        lowerBound += (row - 1);
                    }
                    lowerBound                = "q";
                    lowerBound               += (row - 1);
                    chartRange                = xlWorkSheet.get_Range("a1", "q1");
                    chartRange.Font.Bold      = true;
                    chartRange.Interior.Color = 18018018;
                    xlWorkSheet.UsedRange.Replace("&gt;", ">");
                    xlWorkSheet.UsedRange.Font.Size = 9;
                    xlWorkSheet.UsedRange.WrapText  = true;

                    MessageBox.Show(string.Format("Test Cases exported successfully to specified filepath: {0}", filePath));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                finally
                {
                    xlWorkBook.Save();
                    xlWorkBook.Close(true, misValue, misValue);
                    xlApp.Quit();

                    releaseObject(xlApp);
                    releaseObject(xlWorkBook);
                    releaseObject(xlWorkSheet);
                    this.Cursor = Cursors.Arrow;

                    btnExport.Enabled       = true;
                    btnCancel.Enabled       = true;
                    btnTeamProject.Enabled  = true;
                    btnFolderBrowse.Enabled = true;
                    comBoxTestPlan.Enabled  = true;
                    comBoxTestSuite.Enabled = true;
                }
            }
            else
            {
                MessageBox.Show("All fields are not populated.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }