软件工程课件:10-BehaviorDriven_第1页
软件工程课件:10-BehaviorDriven_第2页
软件工程课件:10-BehaviorDriven_第3页
软件工程课件:10-BehaviorDriven_第4页
软件工程课件:10-BehaviorDriven_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Outline1Features and RequirementsSpecification by ExampleBehavior Driven DevelopmentCucumberSummary2What, exactly is this system supposed to do?Feature vs RequirementsWhat is a requirement? A requirement is a capability that a product must possess or something a product must do in order to ultimatel

2、y satisfy a customer need. What is a feature?A feature is a set of related requirements that allows the user to satisfy a business objective or need. 3/classes/comp415/s12/SitePages/features%20vs%20requirements.aspxExampleFeature1 Click Ordering RequirementsUser shall be able to activate 1-click ord

3、ering within his account.User shall be able to deactivate 1-click ordering within his account.User shall be able to order books with just 1-click.Test First Development 4To Write test before code RequirementsWe need requirements that are easy to write tests for.TestableRequirementsSpecification by E

4、xample Gojko Adzic, to have a broader contextual understanding of a Feature. Specification by Example is the process by which teams build software through the effective use of Examples. Defining requirements through examples allows the entire team to provide input to the contextual definition of the

5、 feature. Each row in an Example table is considered an individual test, how it gets developed (i.e. unit, integration, automation or manual) is up for the team to determine. 5Behavior = Examples = Context = Acceptance CriteriaExamples = Acceptance CriteriaBehavior driven development provides the fo

6、llowing process for defining a testable feature:Similar to Use case development 6GivenAnd WhenThenAndAn Example7Feature / User StoryIdentify the test scenariosIdentify the variablesAs a customer, I want to withdraw cash from an ATM, so that I dont have to wait in line at the bank. Scenario 1 Account

7、 is in CreditScenario 2 Account is OverdrawnWhat are considered customers (personal, business, corporate)?What are considered accounts (savings, checking, credit)?An Example8Given / When / Then Building the Behavior of Your Test First Given- Some initial context- Example: User type- Set up any preco

8、nditions When- an event occurs- Submit a page, click a link, select an optionThen- The expected responseAnd- Use with Given, When and Then when multiple steps need to be executed. An ExampleScenario 1. Account is in CreditGiven Im a customer with a valid accountAnd My Account is in CreditScenario 2.

9、 Account is OverdrawnGiven Im a customer with a valid accountAnd My Account is Overdrawn9When When I withdraw money from my account.When When I withdraw money from my account.ThenThen my account should be debited. AndRequested amount should be dispensed. ThenI should receive an error message. AndReq

10、uested amount should not be dispensed. Appropriate Usage Dont try to include everything in a single GIVEN statement. User parameters to identify different paths the test can take. Keep the WHEN statement to one specific actionEnsure that the WHEN statement is not a preconditionExample: WHEN there is

11、 cash in the ATM dispenser AND I withdraw cash from my account“cash in dispenser” is not an action and should be a pre-condition in the Given statementKeep the THEN statement to the expected result/outcome of the action identified in the WHEN statement10Using Parameters and Example Patterns for Perm

12、utations11Given Im a And I have a valid account type And My account is in CreditWhen I withdraw money from my accountThen my account should be debited And The requested amount should be dispensedUser_typeYes/noAccount_typeConsumerYesCheckingConsumerYesSavingsSmall BusinessYesCheckingSmall BusinessYe

13、s SavingsConsumerNo New account pageExample TableParametersA Brief Summary12RequirementsBehaviorFeaturesScenariosSpecTool Support: Cucumberhttp:/CDan North, and the Agile communityInitiated in April 2008, and long stories before and afterA software requirements and testing tool that enables a style

14、of development that builds on the principles of test-driven developmentWritten in Ruby, works with Ruby, Java, .NET, Flex or web applications13A Quick Tutorial141. Describe behavior in plain text. 2. Write a step definition in Ruby. 3. Run and watch it fails. 4. Write code to make the step pass. 5.

15、Run again and see the step pass. 6. Repeat 2-5 until green like a cuke. 1. Feature Scenario15Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into th

16、e calculator When I press add Then the result should be 120 on the screen 2/3 Test16Given /I have entered 50 into the calculator/ do calculator = Calculator.newcalculator.push (n.to_i)End 4/5 Coding17class Calculator def push (n). endEnd 6. cucumber!18How Cucumber Works 19FeatureScenarioStepStepDefi

17、nitionFrameworkSystemRequirements(text files)Implementation(code)Non-technical customersMagicmappingGherkin Gherkin is the language used to write features, scenarios, and stepsThe purpose of the language is to help us write concrete requirementsConsiderCustomers should be prevented from entering inv

18、alid credit card detailsVersus If a customer enters a credit card number that isnt exactly 16 digits long, when they try to submit the form, it should be redisplayed with an error message advising them of the correct number of digits. The latter is much more testable; we want to remove as much ambig

19、uity as possible in our requirements since ambiguity is a proven source of errorsGherkin is designed to create more concreate requirements20ExampleFeature: feedback when entering invalid credit card detailsIn user testing, weve seen a lot of people who make mistakesBackground (pre-condition, true fo

20、r all scenarios below)Given I have chosen an item to buyAnd I am about to enter my credit card numberScenario: Credit card number too shortWhen I enter a card number that is less than 16 digit longAnd all the other details are correctAnd I submit the formThen the form should be displayedAnd I should see a messa

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论