从Visual Studio C中的测试方法调用测试方法#

时间:2015-08-11 13:17:31

标签: c# unit-testing testing coded-ui-tests

我在USERSTORY的基础上合并测试用例。     给出的是合并测试用例的示例。     WorkItem是正在合并的测试用例的测试用例ID。     在Windows中使用Coded UI。

  [TestMethod()]
        [TestCategory("Assessment"), TestCategory("US6540")]
        [Priority(2)]
        [WorkItem(16178), WorkItem(16180), WorkItem(16182), WorkItem(16183)]
        [Owner("...")]

        public void VerifyThatTeacherWillViewAllUnitsPresentinSectionFromAssessmentManagerPage()
        {
            try
            {
                Login login = Login.GetLogin("AssessmentTeacher");
                TaskInfo taskInfo = login.GetTaskInfo("ELA", "Assessment");
                NavigationCommonMethods.LoginApp(login);
                String[] UnitStatus = AssessmentCommonMethods.LoadUnitStatusFromAdditionalInfo(login);
                AssessmentCommonMethods.ClickAssessmentInDashBoard(UnitStatus[4]);
                Assert.IsTrue(AssessmentCommonMethods.VerifyListOfAllTheItemsAvailableinUnitTitleDropDown(), "All Units not Present in  Section in Assessment Manager Page");
                //16178
                //VerifyThatTeacherWillViewAllUnitsPresentinSectionFromAssessmentManagerPage

                AutomationAgent.Click(100, 100);
                AssessmentCommonMethods.AssessmentUnitSelection(10);
                Assert.IsTrue(AssessmentCommonMethods.VerifyUserIsNavigatedToUnit(10), "User is not navigated to correct unit");
                //16180
                //VerifyThatUnitDisplayIsClickable

                AssessmentCommonMethods.OpenUnitSelectionDropDown();
                Assert.IsTrue(AssessmentCommonMethods.VerifyAssessmentUnitSelection(10), "Assessment unit selection drop down not opened");
                AutomationAgent.Click(100, 100);
                Assert.IsFalse(AssessmentCommonMethods.VerifyAssessmentUnitSelection(10), "Assessment unit selection drop down opened");
                //16182
                //VerifyThattheUnitDropDownCanBeDismissedByTappingAnywhereOnThePage

                AssessmentCommonMethods.ClickBackButtonInAssessmentOverview();
                Assert.IsTrue(DashboardCommonMethods.VerifyUserIsOnDashBoard(), "User is not moved back on dashboard");
                //16183
                //VerifyBackButtonFunctionalityDisplayedOnUnitDisplayBar
                NavigationCommonMethods.Logout();
            }
            catch (AssertFailedException Ex)
            {
                string msg = Ex.Message;
                Logger.InsertExceptionMessage(msg);
                throw;
            }
            catch (Exception Ex)
            {
                string msg = Ex.Message;
                Logger.InsertExceptionMessage(msg);
                throw;
            }
        }

我想确保当其中一个测试用例失败时,它应该返回带有通过或失败状态的测试用例id。你可以看到测试用例ID被评论在哪里特定的验证已经完成了。 让我们假设第一个Assertion语句变为true,那么它应该返回由visual studio生成的报告中的测试用例id。 然后,在下一个断言语句失败之后,报告应该包含已通过的测试用例id和其余失败的测试用例id。

0 个答案:

没有答案