I'm trying to build a new framework based on Cucumber and Page Object Pattern. Could you please advice me what approach to take based on your experience before doing automation project like:

  • What's the structure of project?
  • How can I organize code to be able re-useable for 2 projects (the framework will be applied for other projects but different step_definitions)?
  • What language are you planning to use? – testerab Jul 14 '15 at 7:58
  • @testerab: I'm planning to use Java or Ruby. – scorpion Jul 14 '15 at 8:03
  1. Create .feature files describing your features and scenarios that provide examples of the behavior of those features.
  2. Implement step definitions for the steps in your scenarios
  3. Extract 'helper methods' that interact with your application via the Page Object pattern (if you are testing through the UI)

Ad 3. You might also want to distinguish 2 layers of helper methods: 3a. Actions that perform verification on your application (such as verify an element is visible, has a certain value, whatever) 3b. Interaction with your application via the Page Object pattern, which contain only the controls but have no opinion on whether the actual state is the expected state (as that is determined in your verification actions, see 3a)

You project setup (in Java) would be:

├── pom.xml*            (containing our Cucumber and JUnit dependencies)
└── src
    ├── main
    │   └── java        (marked as sources root)
    │   └── resources   (marked as resources root)
    └── test
        ├── java        (marked as test sources root)
        └── resources   (marked as test resources root)
                └── <project>
  • pom.xml - assuming you are using Maven to import your dependencies, and JUnit to run your tests, your pom.xml should include the following dependencies to use Cucumber java: <dependencies> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>2.3.1</version> <scope>test</scope> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-junit</artifactId> <version>2.3.1</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies>

(Disclaimer: I cannot advise on Ruby dependency management or structure as I don't use Ruby myself - but it should be something similar)

In addition, you will likely use Selenium to interact with your web pages.

For your consideration: if your intention is to test the internal business logic of the application, consider testing below the GUI - as testing through the UI tends to be slow and flaky.

Also, I highly recommend "The Cucumber for Java book" (if you will be using Java), or "The Cucumber book" (for Ruby).

You can also have a look at the https://github.com/cucumber/cucumber-java-skeleton project to get started with Cucumber java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.