Business Workflow
A Business Workflow is a sequence of steps that an end user performs with the application under test. Typically, you would assert or verify something about the system after some actions are performed.
A Business Workflow has an underlying code associated with it. The actual mechanics of driving the application is done in the code.
Create Business Workflow
Workflows are represented in the scenario editor as a bulleted list. If a workflow step fails when a scenario is executed, the execution of that scenario stops and the scenario execution is marked as failed.
It is advisable to specify the workflow steps in a way that is not closely tied to the underlying user interface of the application, as this can make the scenario fragile.
You can parametrize Workflow steps by passing data within quotes. You can then move the parameters around to improve readability of the test intent by Rephrasing the workflow steps.
You can also create a business workflow by just typing in a ":" and pressing the return key.
If there are one or more workflow fixtures on the fixture line from which no workflow step has been used, you may remove the unused fixtures from the fixture line by using "Organize Fixtures" option in the context menu or hitting Ctrl + Shift + O
Implement Business Workflow
Select Quick Fix from context menu or hit Ctrl + 1 on the workflow step to be implemented. Twist gives you option to implement the step in any of the current workflow fixture or any other fixture in the test suite.
When we choose to create a method in any other fixture, a dialog appears giving a list of all existing fixture in the current project as shown below.
We may either choose the fixture from the list or type in the fixture name.
The list gives all fixtures in the project which is used at least once in any scenario, except the once which is used in current workflow.
If at any point in time, the fixture chosen or typed in is unimplemented, Twist creates the fixture followed by the creation of the method in it.
Rename Business Workflow
You can change the name of your business workflow by using Rename option available in the Context Menu. This renames the Workflow's name and also renames the underlying implementation.

Using Content Assist
Twist provides Content Assist facility that suggests possible actions at the point of invocation. Content Assist can be invoked by pressing Ctrl+Space.
When you use Content Assist, the list drawn will contain a list of available workflow steps project-wide. These steps can be further filtered based on the text typed in and on choosing the step, the workflow containing the step itself is added onto the scenario.
You can use Content Assist on the workflow fixtures similar to how you use it on workflow steps.
The workflow fixtures are automatically imported when you content assist and select the workflow step.


Generate Code using Quick Assists
You can create a new stub method in the corresponding class by using Create Method Quick Assist which is invoked by Ctrl+1 and by pressing Return, or by selecting QuickFix from the context menu will create a new stub method in the corresponding class.
Create Stub Methods and Classes
Twist generates stub methods and classes for the workflow steps created. The option Quick Assist is used to get Twist to create code when it does not yet exist. It is invoked by Ctrl-1 or by selecting Quick Fix from the context menu.

Refactoring
Rephrase Workflow Steps
The Rephrase Step in Twist is a combination of Rename and Change Method Signature. . You can access this option through the context menu.
This option allows you to
- modify the name of a workflow step
- change the order of parameters
- add parameters
- edit parameters - current parameters are highlighted and cannot be edited, however newly added parameters are editable.
- remove parameters - backspace or delete right next to the parameter removes the entire parameter
Once any or all these changes are performed you will notice that the workflow step has been updated in both the scenario as well as the Java code. At any point, you can click the Reset button to reset the new step to the current step.
Introducing parameters from underlying Fixtures
Often you have constants in your fixture code that you would prefer to include in your scenario. For instance, recording a workflow step on a web environment often embeds the html identifiers in your code. You may want to introduce those identifiers as parameters in your workflow step.
As an example, consider the following scenario:Workflow:
- buy book of Agatha Christie
public void buyBookOfAgathaChristie() {
application.buyBook("Five little pigs");
}
You can use Introduce Parameter Refactoring in the underlying work flow step method which
automatically inserts the parameter in the corresponding Workflow step as well.
If you select "Five little pigs" and use the Introduce Parameter option in the Refactoring options in Context Menu, you would see that the underlying code changes as follows:
public void buyBookOfAgathaChristie(String string1) {
application.buyBook(string1);
}
If you now go back to the Scenario, you would observe that the Scenario is modified as follows:
Workflow:
- buy book of Agatha Christie "Five little Pigs"
When you Introduce a Parameter in the underlying code, all scenarios that use the underlying code get modified.
Push To Implementation
The Push To Implementation in Twist is a specific operation that allows a user to achieve abstraction in the underlying implementation by grouping a set of workflow steps.
The selected workflow steps are grouped together, and you can choose to name this group of steps in a manner that reflects what these group of steps would achieve or test. The individual workflow steps re now replaced by one single step with the name you have chosen.
You will also notice that in the underlying code, that the grouped steps are included in a new method with the same name as the newly created workflow step.


