Create a Scenario

You now have a simple Twist project created. Notice that you have an empty scenario in this project. The next step is to describe this scenario.

A Twist Scenario allows a user to express acceptance criteria using the language of the domain. A scenario expresses test intent, while its implementation describes how the scenario is actually executed. The underlying implementation is written in Java code. Twist's Scenario Editor allows you to navigate from a scenario to its underlying implementation and back.

  1. Let us type in a simple description for the scenario. Now let us insert a Business Workflow to describe the test intent. Hit Ctrl+Space on a new line, and select Insert a Business Workflow as shown below.

    describe scenario1
  2. Now rename the inserted Workflow to 'At Google'. Type in a couple of workflow steps as shown below. You will now have two unimplemented workflow steps.

    describe scenario2
  3. Let us now implement this workflow. Hit Ctrl+1 on the workflow name 'At Google' to create the underlying code. Hit Ctrl+1 again on each workflow step to create them.

    describe scenario3
  4. In the workflow fixture created, copy and paste the code snippet given below. This code implements the two workflow steps.

    public void searchFor(String searchString) {
      selenium.open("http://www.google.com");
      selenium.type("q", searchString);
      selenium.click("btnG");
    }
    
    public void verifyShowsUpInResults(String verifyString) {
      assertTrue(selenium.isElementPresent("link=" + verifyString));
    }
    
  5. Include this import statement above your class.
    import static org.junit.Assert.*;
    
    Your class should look like the following
    import static org.junit.Assert.*;
    public class AtGoogle {
    
      private TwistSelenium selenium;
    
      public AtGoogle(TwistSelenium selenium) {
        this.selenium = selenium;
      }
    
      public void searchFor(String searchString) {
        selenium.open("http://www.google.com");
        selenium.type("q", searchString);
        selenium.click("btnG");
      }
    
      public void verifyShowsUpInResults(String verifyString) {
        assertTrue(selenium.isElementPresent("link=" + verifyString));
      }
    }
    
    Save the scenario. We now have a fully functional simple scenario created successfully.

Let us now see how to Execute the Scenario