Behavior Driven Development and Test-Driven Development

Course Number:


This course covers Behavior Driven Development (BDD) concepts of  “write your tests first” and “fail first”. This will drive your development process in a “test-implement-test pass-refactor” cycle.  Cucumber-JVM together with JUnit provides the basis for the hands-on aspects of the course.  Through a series of practical exercises, students will translate scenarios into runnable acceptance tests using Cucumber-JVM. As such various testing patterns and approaches will be explored including the utilization of isolated testing via Stubs, fakes and Mock objects In students will leverage the evolution of User stories into code and the have the ability to test Web Application via the Selenium API. This course is about 50% lecture & 50% discussion / hands-on exercises.


This training session is for developers, testers, business analysts and product owners, to enable them to apply BDD principles and practices to steer their projects with acceptance tests at the level of requirements and user stories.
Course Duration:
3 Days


It is recommended that participants have experience working in Java.

Course Objectives:
  • Capture the core JUnit syntax
  • Use BDD and the test-fail-first approach
  • Translate business requirements into user stories with acceptance tests
  • Learn how to Refactor to clean up your code
  • What makes your code testable
  • Use Fakes and Mocks for isolated unit tests
  • Use Cucumber-JVM to turn User Stores into Code
  • Explore the Selenium API
Course Outline:


JUnit Overview

  • Unit Testing
  • Testing with JUnit, the test lifecycle – @Before, @After, @BeforeClass, @AfterClass, @Test
  • Writing assert methods – assertEquals, assertSame, assertTrue, assertFalse, assertNull
  • Hamcrest Matchers and using the assertThat
  • Using is, or, contains, hasItem, equalTo
  • The allOf and anyOf matchers

Test Driven Development (TDD)

  • Principals and Techniques
  • TDD Metaphors
  • Benefits, Challenges and Limitations
  • Handling Requirements Change
  • Characteristics of good tests
  • Revisit Anti Patterns

Testable Designs (Mocks, Fakes and Stubs)

  • Creating testable Code, If you cannot test it what use is it?
  • Strategies for Testable Code
  • Test Unfriendly features
  • Interfaces are great!
  • Stubs, Fakes and Mocks
  • Mocks as Collborators
  • Mocks and return values, void methods, frequency calls and ordering

Behavior Driven Development (BDD) with Cucumber

  • Writing User Stories
  • Acceptance criteria
    • Bridging the communication gap between business stakeholders
  • Introduction to Cucumber
  • Writing scenarios with Gherkin
    • Gherkin syntax
    • Using given, when, then
    • Java, Ruby or Groovy Fixtures generated from scenarios
  • Using JUnit to run your Cucumber stories and scenarios
  • Writing set-up and tear down code using hooks (@Before and @After)
  • Automate Cucumber steps to drive your application both through and below the user interface
  • Refactor Cucumber step definitions to make them more readable and maintainable

Testing Web sites with Selenium

  • Using a WebDriver to test web applications and the Selenium API
  • Interrogating a response page
  • Simulating links and form submissions
  • Simulate multiple page navigation
  • Continuous Integration

Related Posts

About Us

IT Training, Agile Ways of Working and High Impact Talent Development Strategies

Let Us Come to You!

Classes recently delivered in: Atlanta, Boston, Chicago, Columbus, Dallas, Detroit, Indianapolis, Jerusalem, London, Milan, New York, Palo Alto, Phoenix, Pittsburgh, Portland, Raleigh, San Antonio, San Diego, San Francisco, San Jose, Seattle, Springfield, Mass., St. Louis, Tampa and more!