Skip to content

Developer Guide

amitmindstix edited this page Jan 15, 2018 · 10 revisions

General concepts

  1. A module is a set of distinct features like cart, gallery etc.
  2. Features under cart module could be checkout, addtowishlist etc.
  3. Each feature can have scenarios. e.g. Checkout single product, Checkout multiple products
  4. Each module would have its own sub folder and subpackage.
  5. All feature files will reside under its module.
  6. All test classes (step definitions) reside under sub package for that module.
  7. All test classes will be named as <Featurename>Test.java
  8. Each scenario can have one or more tags. Typically tags include module, feature, test-type, test-priority
  9. e.g. @cart @checkout @singleproduct @smoke @medium
  10. Tags can also be given at feature file level (typically module and feature level tags)

Source code organization

Source tree of the project looks like below -

Java code

  • data - Contains classes that represent test data
  • page - Contains POM classes (page object model). This can have sub packages based on modules
  • utils - Contains utility classes
  • runner - Contains Cucumber runner class - refer RunnerCourgette.java for more details
  • stepdefinition - Contains cucumber step definition classes (aka glue). This can have sub packages based on modules

resources

  • feature - Contains cucumber feature files (may have sub folders based on modules)
  • testdata - Contains test data files
  • selectors.properties - Selectors (externalized for ease of collaboration)
  • log4j.properties - Logging configuration (default log output is at Logs/testlogs.log)

Other files

  • build.gradle - Gradle build script
  • gradle.properties - Gradle configuration. Versions of dependencies and other variables
  • docker-compose.yml - Docker Compose definition of selenium-grid
  • gradlew - Shell script to run gradle (Linux/Mac)
  • gradlew.bat - Script to run gradle on Windows
  • pom.xml - Maven build script. Deprecated. Please use gradle instead of maven. Future version may drop maven support
  • .travis.yml - Travis CI configuration file. Ignore this if you are not using Travis.
  • Jenkinsfile - Jenkins Pipeline definition - supporting selenium grid, slack, email notifications
  • Jenkinsfile-minimal - Jenkins Pipeline definition with least complexity - used for local development

Runner

We use Courgette runner instead of plain JUnit runner. For reference documentation - see this Usage Snippet as below -

@RunWith(Courgette.class)
@CourgetteOptions(
	    runLevel = CourgetteRunLevel.FEATURE,
	    showTestOutput = true,
	    rerunFailedScenarios = false,
	    threads = 2,
	    cucumberOptions = @CucumberOptions(
	    		  features = {"src/test/resources/feature/ecom",					      
                                        "src/test/resources/feature/setup",
                                        "src/test/resources/feature/api"},
	    		  tags = "@cbt",
	    		  dryRun = false,
	    		  strict = true,
	    		  monochrome=true,
	    		  glue = {"com.mindstix.cb.stepdefinition.ecom",
			              "com.mindstix.cb.stepdefinition.api"},
	    		  plugin = {"pretty", "html:build/reports/cucumberreport/index", 
	    		                  "json:build/reports/cucumberreport/cucumber.json" }
	    		))
  • runLevel - feature level parallelization. Recommended to keep this to default
  • threads - no. of threads to be used to execute parallel tests
  • rerunFailedScenarios - turn to true if you want to execute failed scenarios once again
  • dryRun - turn to true to check if all cucumber steps are defined in java before actually running tests
  • strict - turn to false to allow tests to run even if some steps are not defined in java
  • glue - packages where your step definition classes exist
  • plugin - reporting configuration
  • features - folders where cucumber feature files reside
Clone this wiki locally