How to use Cucumber to write an acceptance test at Feature level? - cucumber

JBehave is Java based & good for Java applications. JBehave also supports good HTML reporting. However, the problem with JBehave is that it only supports Story level and not Feature level.
Can any one here help me with a small explanation or documentation where I can understand how Cucumber supports Feature level?

A feature is an implementation of a capability (a capability might need more than one feature).
Let's look at Mike Cohn's description of a "story", since it's pretty good:
User stories are short, simple descriptions of a feature told from the
perspective of the person who desires the new capability, usually a
user or customer of the system. They typically follow a simple
template:
As a <type of user>, I want <some goal> so that <some reason>.
A good user story follows the INVEST principles, and this is where we start getting into scenarios:
Independent, which means it can be delivered on its own
A story may have one or more contexts in which the feature is going to work. The contexts are by their nature independent of other contexts.
Negotiable, so you can rewrite it
As you work through a story, you may find other contexts or outcomes that need to be considered. The capability which is the core of the feature is usually associated with the "when". For instance, if I wanted to be able to generate a report, the "when" would be, "When I generate the report..."
Valuable, so it delivers value to stakeholders
There may be several stakeholders with different outcomes. For instance, sending an email to say that a cab's been booked is important, but so is sending the booking confirmation to the driver! By considering different stakeholders, we come up with the outcomes for the scenarios that need to be considered.
Estimable, so you can estimate the size
If you can't estimate the size, try just getting one scenario working. This is the functional equivalent of Kent Beck's "spike". Incidentally the only reason you need an estimate is usually to work out whether it's worth doing, given other work that could be done, so treat this accordingly.
Small, which (quick edit as I realised I missed this letter) means you should have some level of certainty about it.
I actually prefer people knowing they have some level of uncertainty about it, and look to get feedback ASAP. If you're really certain about it (eg: login) then it's OK for it to be bigger, because you'll need feedback less frequently; you know what "working" looks like.
Testable, which means the related description must include enough to test it
Examples become tests as a nice by-product of this analysis.
Why do we do stories in the first place, though? Why not just deliver whole features?
It turns out that the work needed to get some features shipped ends up being pretty big, especially if you've got a lot of stakeholders involved, and we want to either slice them up so we can get value from them earlier, or we want to slice them so we can get feedback.
So a story might be a slice through a feature that can actually be shipped, or it might be something designed to get feedback.
Scenarios are a fantastic way of doing this! The feature can be narrowed down to the most valuable contexts, or different stakeholders whose outcomes need to be considered. Be careful not to eliminate stakeholders with transactional needs (the user at the ATM gets their money; the bank debits the account) or regulatory needs (the bank makes a major investment; the regulators see the change in capital reserves).
Scenarios aren't the only way of getting feedback on a feature. New UI? Hard-code it without any behaviour and show it to people. New report? Make up a mock copy. New feed that nobody's ever processed? Make a spike, see if you can get the information out of it that you think you can.
Otherwise, consider different contexts and stakeholders whose outcomes need to be considered, and consider different capabilities with their contexts and outcomes. Features implement the different requirements, whose behaviour is illustrated by the scenarios you've derived.
Since a story is a slice through a feature, and a feature implements a capability, this is a typical hierarchy:
Stakeholder
Goal
Capability
Feature
Story
Scenario
If you're trying to work out how to relate scenarios to stories and features, this isn't a bad way to go. You'll find it familiar if you look at Gojko Adzic's "Impact Mapping" or Matt Wynne's "Example Mapping" (I think we all got it from listening to Chris Matts).
Be careful because in reality this is a bit fuzzy; you'll make discoveries as you start to deliver, so don't break everything down ahead of time. I find capabilities make good planning-level artifacts, and are often associated pretty easily with "Epics". They also come with their own high-level tests: "Can our users do what they need to, for the contexts we need to consider, and the stakeholders whose outcomes are also needed?"
The trick with a story is to only consider what's needed to deliver value, until it's actually delivered... and then some of the rest will be the next thing that's needed, etc.
For more ideas, here's my blog on capability-based planning and lightweight analysis, and another one on splitting up stories.
For Cucumber, organize by capability and then (if you need to) by context, and tag your check-ins with the story number (most CI tools, electronic boards and version control systems support this). It's OK for a feature or story to create more scenarios.

Related

UML - Use Case Diagram choices

I have heard conflicting things about this and just wanted to clarify.
I have always thought that when constructing a Use Case Diagram, I only include the activities that will be carried out by the system. For example, if it were a bank atm, "User depositing money" would be included, as it involved the user interacting with the atm. However, "User is paid cash in hand from job" is not included in the diagram, even though it may bear relevance to a scenario or situation.
Thanks all
The fact that the user is paid in cash is in any way related to the information system which is a system involving people. The payment transaction has to be integrated with your project, at least on a conceptual point of view. In other words it should have a relationship of an unspecified kind with a use case, depending on the context.
I recognize my answer is quite messy: if you're already getting bored, jump directly to the solution section...
The use cases diagram
According to The UML User Guide:
A use case is a description of sequences of actions that a system performs that yield observable results to a particular actor.
The point is about modeling what is related to the system: your main problem is to consider the scope of your project.
Depending on the scope you identify, the use case you should consider would be something like Cash withdrawal: consider the observable results from the point of view of the actor. This part is highly subjective whether you consider the operation part of the system or not. I personally disagree with the other answers here.
A few words about being paid cash in hand. On a pure development process point of view, would it be normal to have a sharp idea how a user is being paid while modeling ? Still the scope question here: perhaps is it a strong constraint in your context.
Even when reverse-engineering, a use case is user-oriented, it has nothing to do with how things are done, but what is done: I think nothing to do with especially automating things, even when talking about a system. There is a subtle idea here: I consider an information system, a system involving people in the first place, not a completely automated system. Of course, purely automated systems can be modeled with UML, but most systems involve users.
The relationship between the use case itself and the information how the payment is done has not to be represented on the diagram figure. However, even if this is not in the use cases spirit, the way it is done could be written in a note if it is an important constraint the diagram reader should be informed of.
The solution
In my point of view, the right place to put that information in the use cases is not the diagram figure itself but in a use case description. Martin Fowler gives a few hints about this in UML distilled. You have a simple use case description example here. This is related to the way you are using UML and the way you wish to describe use cases (I personally share Martin Fowler's perception).
Perhaps you would prefer to represent this with a formalism specific to your modeling software, but I think this would not be a traditional way of using UML (appropriate for an Executable UML, not appropriate with blueprint or sketch).
It is not included because the "User is paid cash in hand from job" is outside the scope of a project and would not be needed for what you are trying to create.
Most often use cases are used at the functional/logical level of your model (MDA's PIM level). This means that it only describes those parts of the process that will be automated.
So unless your system has a feature that somehow records the fact that the user is paid in cash, that isn't part of the system under construction.
At the business/conceptual (MDA's CIM level) level however you model the whole processes, regardless of automation. So at this level it "User is paid in cash from job" would certainly be at its place.

What distinguishes a user story/feature from a use case/scenario?

What distinguishes a user story/feature from a use case/scenario? Any pointers would be very much appreciated.
Is it just the granularity, similar to epics and user stories?
Much has already been written on the meanings of and difference between "use case" and "user story". Google "stackoverflow difference between use case and user story" to see some of it.
Regarding "feature" and "scenario":
In Gherkin, a Scenario is a series of steps that are executed together.
In terms of user stories: it might take one or many Scenarios to specify a user story, depending on the size of the story.
In terms of use cases: Gherkin's use of "scenario" corresponds almost exactly to the meaning of "scenario" in use case analysis: A use case describes a series of interactions between an actor (usually but not always a human user) and the system, in enough detail to make the system's responsibilities clear; a scenario is an instance of that use case with some values and the resulting details of interactions exactly specified, with the purpose of making some fine point of the system's responsibility (often edge case or error handling) clear. Just like a use case scenario, a Gherkin Scenario necessarily specifies all values completely (even if they're hidden in step definitions and not visible in the Gherkin itself), so "Scenario" was a good choice of name for that Gherkin concept.
A Gherkin Feature is just a collection of Scenarios, which you can use however you like.
In terms of user stories: A Feature can be the set of Scenarios that implement a user story or epic. In my experience, after more than one story has been implemented that touches the same part of an application (the same "feature"), one wants to put the Scenarios for those stories in the same Feature so one knows where to find them -- for example, you might want to put all the Scenarios related to user accounts (create an account, upgrade a subscription plan, cancel an account) in the same Feature rather than in different features, even though they implement quite different stories.
In terms of use cases: It usually takes several Scenarios to specify a use case (e.g. one for the happy path and one for an error path). Clearly these belong together in the same Feature file. As with user stories, one often wants to put the Scenarios for use cases that describe the same feature of the software in the same Feature.

How to breakdown a business process workflow into user stories [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
The Product owners have specific requirements around how the Product should enable the users in a complex business process workflow (approvals and what not). The easiest way to document the requirement is in the form of a process diagram/flowchart.
In Scrum however, it is advised for requirements to be in the form of user stories. What is the best way to approach this?
Option 1
Have generic user stories that encompass the workflow, and attach the flowchart diagram as a supporting document. e.g. As an author, I want to be able to submit my article for approval process so that it will get published.
Pros
it's easier for people to understand and digest - rather than reading 10-20 user stories.
Cons
it becomes an epic
Option 2 Break down the complex flowchart into its own user stories. e.g.
As an author, I want to be able to submit my article.
As an editor, I would like to get notified when an article has been submitted so that I can review it.
As an editor, I need to approve an article
As an editor, I would like to be able to request for more information
...
Pros
pure Scrum. easy to prioritize/estimate/plan
Cons
As you can see even a short business process workflow will easily explode into a lot of user stories.
I agree with pma_. Do what makes sense. In this case, you have some great looking user stories.
"As an editor, I would like to get notified when an article has been submitted so that I can review it."
If you have a ton of these, then perhaps they are too small. They would all be 1-2hrs. That's probably not a good thing to have. In that case, try grouping them. Perhaps
"As an editor, I want to be able to manage articles". That would include several of the ones you have already.
Keep in mind the goals of user stories...
Track items on a burndown chart
Deliver fully functional work (not an unusable subset of work)
Have estimatable portions
If you can achieve those goals, you're good. If not, try again.
Oh, and one last thing - keep the flow diagram, don't throw it out in favor of stories. But supplement the stories with it.
If this business workflow is like most business workflows, each of those steps will have a significant number of rules. Those rules should map into acceptance criteria for those stories and ideally, automated tests to prove that the code works as intended. Because of the potential for a lot of acceptance criteria, I would lean towards the second option.
I tend to go towards Features/Epics early on with the core end user/stakeholder value-adding functionality, such as in your example to "Publish an article so that the subscribers can get the latest news". Then once the Feature is getting closer to implementation I'll split it into implementation sized stories if needed.
Most non-trivial business workflows benefit from being split up during implementation so that they can be continiously deployed and verified in order to get early feedback from the stakeholders. The big con of having everything as one big bang implementation is late validation. I think that having early feedback is outweighing the increased administrative burden of handling multiple stories.
A tip on how to split epics into stories: Lasse Koskela has a great writeup on how to split stories in different ways.
For me all agile is about using common sense. I this case you have perfect desing so just implement one and don't look for unecessary things.
We're currently building a business process based content management system. We split our processes into stories as per your 2nd option.
But, of course, we keep the flow diagram handy. In fact, we print it out and stick it to the wall. We even keep every old version of it so we've our own paper based version control stuck to our wall (in addition to using git for the electronic version ;-) )
In Scrum however, it is advised for requirements to be in the form of user stories. What is the best way to approach this?
The two options that you have mentioned are not really options, they are sequential stages, IMHO. During Agile Requirements Gathering or Product Planning the first step is to create EPIC stories. After you have those Epics, you need to break them down into smaller chunks.
Without the EPICs you will most likely to run into the issue of creating random stories without getting a grasp on the sense of belonging of a story. You can in a way create a hierarchy in User Stories. Without understanding that, everything is just random, hence it makes it tougher to wrap your head around or manage the stories as a PO.
Offcourse there is much more to all this than what I mentioned in the above paragraph. That's why probably you need an experienced Scrum Coach or do a lot of diligent reading/implementing on Agile Planning and User Story writing.
Hope this makes sense. I would suggest reading Agile Estimating and Planning by Mike Cohn for anyone who even remotely thinks of taking up a PO role. Best of Luck!
Workflows are an interesting entry to writing user stories and epics, but user stories don't map to work flows, they map to business capabilities. So you are incorporating some fallacious thinking from the start in this question. Workflows are a good tool for the conversation, but will live independently of workflow as they are about functionality, not timing. Timing lives in the business rules.
On that note, business rules are not Acceptance Criteria, they are the connection between Acceptance Criteria, which are features that can be demonstrated by a product owner, and Test Cases. Again, Acceptance Criteria are about features, not behavior. Behavior lives in the business rules.
For instance I might have User Story for an ATM that says "As a user, I can check my account balance." And the Acceptance Criteria could be "If I am overdrafted, I get an alert notice." The rules for what constitutes an over draft (I had $1000 in my account and deposited my $2500 pay check, but that won't clear before my $1500 mortgage payment, etc.) are not acceptance criteria. They are business rules whose execution results in the demonstrable action of the Acceptance Criteria. Note, that this user story could be captured through a workflow analysis, but might live in many workflows (or none).

Under what conditions could we justify an attempt to introduce a one size fits all term when it contradicts working experience?

I have just been re-reading "Domain-Driven Design: Tackling Complexity in the Heart of Software" by Eric Evans. I could not help but notice a hint towards creating a language where there is a one-to-one mapping between a noun and an entity. For example, we might call a phone, a phone and no other noun is accepted. However, can this always been achieved with every other entity. Let us take for example, language used to denote a bid on a phone. Here, there are several different names that refer to a bid on that phone where all these refering names mean the same thing, e.g., negotiate bid, negotiate offer, phone bid, etc. Also, there are additional terms used by other customers. Using these terms interchangably does not cause confusion. Nevertheless, attempts to introduce a single term to be used across all the source code as well as in conversations with all customers can cause confusion.
There is the obverse problem when we talk about similar phones where similar means something different to each customer. Here, we have the same term, which is sought after. However, it has many different meanings.
So, what justification in this instance could be used to attempt to introduce a one size fits all term when it contradicts working experience?
Your argument "begs the question" (in the logic sense of the term).
You ask: "Under what conditions could we justify an attempt to introduce a one size fits all term when it contradicts working experience?" How about under those conditions where it actually doesn't contradict working experience?
You suggest: "attempts to introduce a single term to be used across all the source code as well as in conversations with all customers can cause confusion." Indeed, it can... and it can also avoid confusion.
Source code is a great example of a limited domain where we can expect a minimum level of familiarity and training for all of the users expected to work in that domain (at least, in most commercial settings).
It is quite reasonable for a style-guide to declare the preferred term, and expect everyone to follow it, as consistency in this situation has a big upside. Using your example, in my particular project, I use the term "offer" over "bid" every time, and the code is better for it. I can point to other terms which have not yet been standardised, and can see the extra effort it takes to code for them.
Similarly, it is a widely accepted design goal in User Interface design and in User Documentation to use consistent terms. Using multiple terms for the same item is more difficult for users to follow - particularly non-native speakers. (I disagree with your claim that it does not (ever) cause confusion.) When introducing a new term, it is a good idea to mention other terms that could be used.
(Funnily enough, I worked at an organisation where the User Documentation referred to phones as "Voice Terminals", as the term 'phone' was ambiguous; this was, I suspect, going too far?)
On the other hand, someone selling a product or training users would generally do well to mimic the language of the users to best engage them.
You said,
There is the obverse problem when we talk about similar phones where similar means something different to each customer. Here, we have the same term, which is sought after. However, it has many different meanings.
What about bounded contexts? Probably, when same term means two different things, they should reside in two different contexts?
I quote from Martin Fowler's page on Bounded Context:
As you try to model a larger domain, it gets progressively harder to build a single unified model. Different groups of people will use subtly different vocabularies in different parts of a large organization. The precision of modeling rapidly runs into this, often leading to a lot of confusion. Typically this confusion focuses on the central concepts of the domain. Early in my career I worked with a electricity utility - here the word "meter" meant subtly different things to different parts of the organization: was it the connection between the grid and a location, the grid and a customer, the physical meter itself (which could be replaced if faulty).
His and yours problem descriptions sound similar.

What is the difference between a "feature" and a "story" in Behavior Driven Development?

I am working on a product and I am using Pivotal Tracker to write user stories, but I am quite new to BDD and XP, and newer to Cucumber. So I am getting confused by the terminology a little bit. What is the difference between a story and a cucumber feature? Both are simple descriptions consisting of three parts--actor, action and business value. Right? So if I already have a story written in Pivotal Tracker, should I just copy that directly into the Cucumber feature? Can one story have multiple features?
What do you think?
A feature is a fully-fledged piece of functionality, ready to go live. For instance, a feature might be a user profile, complete with registration page, validation, pictures, etc.
In BDD-terminology, a story is a small slice through the feature which is functional, and on which we can get feedback. For instance, we might produce the registration without a profile page, and without validation. Validation might be another story. Pictures can be another.
It can take weeks to produce some of the more complex features, taking into account architecture, new technologies, domain learning, etc. - so a story lets us get feedback more quickly than this.
You might be interested in learning about Feature Injection - BDD in the analysis space. We use the template quite a lot for both stories and features:
In order to <achieve a goal>
As <the stakeholder who wants the goal>
I want <something>
I tend not to worry too much about whether what I'm doing is a feature or a story, as long as I'm getting feedback as quickly as possible.
"Story" is a series of development tasks which together accomplish a goal. It is a device used by developers.
"Feature" is, well, a feature that the business stake holders want to see in their application. To implement a feature you might need one story, or many, since typically if a story is "too big" it is broken down into more manageable smaller stories.
BDD is a variant on TDD (Test Driven Development). As I understand it, the semantics of BDD are less implementation oriented than the semantics of TDD, in that you use phrases such as 'the system should load the user' instead of "the user instance should not be null after being loaded by the DAO" -- they describe system behavior (feature set) as opposed to specific details of the actual implementation. In the end though, they all test the same thing if done correctly.
And, on topic, the concept of story is really orthogonal to BDD; there are development practices that have Stories and do not have BDD.
Unfortunately feature is a heavily overloaded word in this space and a Cucumber feature is a very different thing to a fully fledged piece of functionality.
The most interesting difference between a 'Cucumber Feature' and a User Story is that a User Story is a historical document, whilst a Feature describes the current state of the application (assuming the feature has been implemented).
This difference is (IMO) much more important than differences in granularity or size. You can have a Cucumber feature that was driven/inspired by many user stories, and you can have a single user story that has many Cucumber features.
Once a Cucumber feature can be run it is code. This means it is much more prone to being refactored and changed. Each time you run it, it gives you information about the current state of your application. A user story tells you about what your application should do. Or perhaps more accurately, what the authors of the story thought you application should do at the time the story was written.

Resources