Twisting the test automation brain to work with TWIST
Listen on the go!
|
Twist is a test automation tool from ThoughtWorks that creates and maintains test automation suites in an Agile environment. Let us dig deeper into various features Twist provides and discover the approach from the perspective of a test automation engineer.
TWISTing Eclipse
Twist allows you to create tests in form of Scenarios/Business workflows or more apt behaviors. Twist is built on the popular eclipse IDE platform. Of course the platform has been customized to enable tool usage.
Twist is based on the concepts of tools like Cucumber, Robot Framework and Fitnesse, but adds a layer of customization to make it more maintainable and readable.
Although Cucumber and Robot have unique ways of creating scenarios, I will present Twist’s differentiators to the stakeholders who are habituated to a more conventional approach of test automation. From my perspective, I will also talk about the disadvantages that Twist has over conventional approaches.
Creating a test scenario with a TWIST
In Twist or any other BDD test tool, the test scripts are maintained as behaviors, scenarios or business workflows. Twist lets you create a scenario which is saved as a .scn(scenario) file and run as a test.
Creating a scenario in Twist is pretty simple. Just click on “Business Workflow” button in the editor and you can start writing your steps.
Refer to the following screenshot:
Each workflow has multiple steps which define the behavior of application. Now that we have seen how to write a simple step, let’s add the complication, because you would want steps to pass some parameters. The succeeding section elaborates how this “English-like” script gets executed (It might not be a surprise to people who have already worked on Cucumber or Fitnesse!!).
Parameterizing the test
As shown in the screen shot of how the parameterization, you essentially specify the parameters in double quotes (“) and Twist understands them to be parameters to the step. The key point here is that only the order of parameters is important, not their position.
Refer to the following screenshot:
Data Drive the test?
Now that we have parameterized the test, it is time
we data drive it as per Twist’s rule table. This is similar to Cucumber’s examples. Of course, Twist adds a bit of intuition to the way we data drive tests using something called rules tables where user can create a table with related data.
Nesting the steps and complicating it all
Now that we have parameterized and created data driven tests, it is time to include some reusability into our tests. This can be achieved in multiple ways in Twist
- Push to Implementation
- Create a Concept
Push to Implementation is a way to combine multiple steps to create a single step, and name it accordingly. So if you have multiple steps which can be clubbed to form a single logical unit such as “Login” which includes steps to combine entering username, password and click submit, you can just select the steps, right click and “Push To Implementation”. The following picture depicts how a step using Push to Implementation looks after the
This approach definitely helps in terms of reusability since there is a good scope in the twist documentation for parameterizing such re-factored tests. However, these re-factored tests become complex if not implemented appropriately.
Context and Concept
There are two other important features in Twist, Context and Concept.
Concept is similar to Push to Implementation except that the steps are not combined at the code level. This type of implementation helps in defining a process or business workflow with a single step, which in turn has detailed steps in a different scenario and increases reusability.
On the other hand, Context is more like a Setup method in the unit test frameworks. It is used to define a particular pre-condition to be achieved before starting the actual test. This feature is available in many open source tools like cucumber as Background.
Loops and Conditions?
As I have said, Twist is not a tool where you can write loops and conditions in the scenarios. Scenarios are plain steps; all the looping and other implementations are in the code. Yes, you still have to code!! So for those of you who are already comfortable with coding you need to twist your approach as Twist adds another layer to write your tests, which is in English (English-like) scenarios. So some of you may ask, what is Twist doing then? Here is what Twist does; when you take a BDD approach and Business or Dev, it defines the behavior of application as scenarios. The automation engineer still has to do the coding, so your job is safe!
So, where is the actual tool? – Selecting a driver
Twist is not a GUI testing tool. Yes, you heard it right. Twist is more of a framework, an approach to maintain your tests (in English). You still need a tool like Selenium or Sahi to run your implemented code on the AUT. So if you call Twist a tool, because it helps manage your tasks effectively, it is. But if you call Twist a GUI testing tool, well, it is not.
Twist helps you to select a driver like Selenium or Sahi. If you had to integrate your own driver, you would have to create a bean. For those who are not too familiar with Java beans, just forget about integrating your tool with Twist and run to a developer. For those who are aware, Twist provides an example of how to do it.
In this particular case, Twist looks kind of rigid and not very flexible. With tools like Cucumber, you just need to import the libraries in step definitions and start implementations with the tool apis, so they are far more flexible and scalable here!
Languages?
For now all I know, Twist supports only Java. Some of you might say it supports English too, but you still need Java to implement methods :).
As for tools like Cucumber, it supports various languages apart from Java (like Python, Perl or C#) and over 40 spoken languages. Based on my experience with its current architecture, Twist is not that scalable.
My take on Twist
Twist is the tool for you if you want to sell the whole concept of BDD due to the intuition it provides. If your management is already sold on BDD or a similar testing approach, there are many open source tools like Cucumber, JBehave or Robot Framework which can be scaled extensively to match your needs.
Twist is not a GUI test automation tool by itself; it is just a framework with drivers for other open source GUI test tools like Selenium. Twist can also be extended to support multiple drivers but the scope is limited to integration. If you are looking forward to Twist as a one stop solution for all your test automation needs, well it is not.
Comment (1)
[…] Test automation in agile projects is best developed incrementally and it should start parallel to development so that time that can be utilized for testing is not wasted in enabling automation. Test automation should be a well-thought-out process for it to be cost effective and generate ample returns. […]