All Projects → CodemateLtd → Android-Cucumber-BDD-Sample

CodemateLtd / Android-Cucumber-BDD-Sample

Licence: Apache-2.0 License
A sample project that has most of the tests and code written in a Behaviour Driven Development style, using the Cucumber framework.

Programming Languages

java
68154 projects - #9 most used programming language
Gherkin
971 projects

Projects that are alternatives of or similar to Android-Cucumber-BDD-Sample

scenari
Clojure BDD library - Executable Specification with Behavior-Driven Development
Stars: ✭ 57 (+96.55%)
Mutual labels:  bdd, cucumber, behavior-driven-development
Behat
BDD in PHP
Stars: ✭ 3,696 (+12644.83%)
Mutual labels:  bdd, cucumber, behavior-driven-development
cucumber6-ts-starter
Starter project to write and debug cucumber-js features in TypeScript language
Stars: ✭ 62 (+113.79%)
Mutual labels:  bdd, cucumber
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+21913.79%)
Mutual labels:  bdd, cucumber
cucumber-steps
🥒 Quick start for testing with Cucumber.js
Stars: ✭ 15 (-48.28%)
Mutual labels:  cucumber, cucumber-framework
docs
Cucumber user documentation
Stars: ✭ 110 (+279.31%)
Mutual labels:  bdd, cucumber
justtestlah
Dynamic test framework for web and mobile applications
Stars: ✭ 43 (+48.28%)
Mutual labels:  bdd, cucumber
kekiri
A .NET framework that supports writing low-ceremony BDD tests using Gherkin language
Stars: ✭ 19 (-34.48%)
Mutual labels:  bdd, cucumber
Nightwatch Cucumber
[DEPRECATED] Cucumber.js plugin for Nightwatch.js.
Stars: ✭ 243 (+737.93%)
Mutual labels:  bdd, cucumber
gavel-spec
Behavior specification for Gavel, validator of HTTP transactions
Stars: ✭ 105 (+262.07%)
Mutual labels:  bdd, cucumber
codeceptjs-bdd
Javascript BDD UI Automation Framework. Exclusive LWC Shadow DOM Support. Playwright, Webdriver.io, Appium, Saucelabs.
Stars: ✭ 35 (+20.69%)
Mutual labels:  bdd, cucumber
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-20.69%)
Mutual labels:  bdd, cucumber
demo-webdriverio-cucumber
E2E Tests with WebdriverIO and Cucumber
Stars: ✭ 28 (-3.45%)
Mutual labels:  bdd, cucumber
e2e-testing
Formal verification of Elastic-Agent and more using BDD
Stars: ✭ 22 (-24.14%)
Mutual labels:  bdd, cucumber
django-aloe-bdd
BDD with Django and Aloe
Stars: ✭ 27 (-6.9%)
Mutual labels:  bdd, behavior-driven-development
codeceptjs-bdd
⭐️ ⭐️⭐️ Migrated to Salesforce Open Source Platform - https://github.com/salesforce/codeceptjs-bdd
Stars: ✭ 24 (-17.24%)
Mutual labels:  bdd, cucumber
mocha-cakes-2
A BDD plugin for Mocha testing framework
Stars: ✭ 44 (+51.72%)
Mutual labels:  bdd, cucumber
Add
Разработка с управляемым качеством на 1С
Stars: ✭ 210 (+624.14%)
Mutual labels:  bdd, cucumber
Gauge
Light weight cross-platform test automation
Stars: ✭ 2,622 (+8941.38%)
Mutual labels:  bdd, behavior-driven-development
cucumber-performance
A performance testing framework for cucumber
Stars: ✭ 28 (-3.45%)
Mutual labels:  bdd, cucumber

Behavior-Driven Development with Cucumber

Build Status Coverage Status

Sample Video

This is a sample Android app that has BDD-style tests made using the Cucumber framework. The app acts like a library book search, allowing you to search for books by title, author or year.

Cucumber is a BDD testing framework that allows people without programming background write specifications that can be translated to unit test requirements almost automatically.

The feature file that has all functionality requirements that the application must fulfill is located here.

An example

The Springfield City Library needs a simple mobile app for searching their book collection while away from their computer. For the first version of the search feature, there's only one thing to implement:

  • the employees must be able to search for books by authors.

This translates to the following Gherkin syntax, which could be even written by the customer or project lead.

booksearch.feature:

Feature: Book Search
    Scenario: Search books by author
      Given there's a book called "Tips for job interviews" written by "John Smith"
        And there's a book called "Bananas and their many colors" written by "James Doe"
        And there's a book called "Mama look I'm a rock star" written by "John Smith"
      When an employee searches by author "John Smith"
      Then 2 books should be found
        And Book 1 has the title "Tips for job interviews"
        And Book 2 has the title "Mama look I'm a rock star"

Simple, isn't it? This can easily be read and understood by non-programmers!

From that file, Cucumber pretty much autogenerates the Regular Expressions and Annotations needed to match the specific criterias. Then we only need to add the test logic and if we want, modify the method names.

BookSearchSteps.java (annotations and methods auto-generated):

public class BookSearchSteps {
    private Library library = new Library();
    private List<Book> searchResults = new ArrayList<>();

    @Given("^there's a book called \"([^\"]*)\" written by \"([^\"]*)\"$")
    public void addBook(String title, String author) throws Throwable {
        Book book = new Book(title, author);
        library.addBook(book);
    }

    @When("^an employee searches by author \"([^\"]*)\"$")
    public void searchForAuthor(String authorQuery) throws Throwable {
        searchResults = library.findBooksByAuthor(authorQuery);
    }

    @And("^Book (\\d+) has the title \"([^\"]*)\"$")
    public void verifyBookFound(int position, String title) throws Throwable {
        int realPosition = position - 1;
        assertEquals(title, searchResults.get(realPosition).getTitle());
    }
}

Now that we have the tests in place, we just implement the functionality to make the tests pass!

License

Copyright 2016 Codemate Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].