Blog settings

As a blogger I should be able to change my blog settings so that I can customize it.

One way want to express the functionality is

Configure Blog
  • Login as "username" and "password"
  • Go to configuration option
  • Rename the blog name to "TwistedBlog" description to "My Thoughts on Twist"
  • verify that the blog name is "TwistedBlog" and description is "My Thoughts on Twist"
Logging into the system with a valid username and password is a prerequisite for many stories. Also, we would like to logout of the system once the test is complete.

Logging in and Logging out, however truly do not "belong" to the story. We do not want to unnecessarily clutter our Workflows with such peripheral details.

This is a good case to model the login as "username" and "password" operation as a Context.

Create a context by clicking on the Add button. Type in "Login". Click on the drop down arrow next to the Context and select Create

You could implement the Context as follows:
public class LoginAsWith {

    private final Login login;

    public LoginAsWith(TwistSelenium selenium) {
        this.login = new Login(selenium);

    }

    public void setUp(String user, String pass) {
        login.loginAsWith(user, pass);
    }

    public void tearDown(String user, String pass) {
        login.logoutFromTheBlog();
    }

}    

We can implement any setup activities as part of the setUp method. Similarly we can do any cleanup in tearDown. Observe that we have reused the Login class in the Context's implementation, instead of writing hand-crafted Selenium scripts.

Our test now becomes:-
Blog Configuration:
  • Go to configuration options
  • rename the blog name to "Twisted Blog" description to "My Thoughts on Twist"
  • verify that the blog name is "Twisted Blog" and description is "My Thoughts on Twist"

Proceed to Creating blog entries.