Top Related Projects
A home for issues that are common to multiple cucumber repositories
BDD, Python style.
BDD library for the pytest runner
The Enterprise-ready testing and specification framework.
Quick Overview
Kiwi is a Behavior-Driven Development (BDD) testing framework for Python. It allows developers to write human-readable test scenarios using Gherkin syntax and execute them as automated tests. Kiwi aims to bridge the gap between technical and non-technical team members by providing a common language for describing software behavior.
Pros
- Easy to read and write test scenarios using natural language
- Promotes collaboration between developers, testers, and business stakeholders
- Supports integration with popular testing tools and CI/CD pipelines
- Extensive documentation and active community support
Cons
- Learning curve for teams new to BDD concepts
- May require additional setup and configuration compared to traditional unit testing frameworks
- Can be overkill for small projects or simple test cases
- Performance overhead compared to lightweight unit testing frameworks
Code Examples
- Defining a feature and scenario:
Feature: User Authentication
Scenario: Successful login
Given a registered user
When the user enters valid credentials
Then the user should be logged in successfully
- Implementing step definitions:
from kiwi import step
@step("a registered user")
def step_registered_user(context):
context.user = create_test_user()
@step("the user enters valid credentials")
def step_enter_valid_credentials(context):
context.response = login(context.user.username, context.user.password)
@step("the user should be logged in successfully")
def step_logged_in_successfully(context):
assert context.response.status_code == 200
assert "Welcome" in context.response.text
- Running tests with tags:
from kiwi import run
if __name__ == "__main__":
run("features/", tags=["@smoke", "@regression"])
Getting Started
- Install Kiwi:
pip install kiwi-bdd
- Create a feature file (e.g.,
login.feature
):
Feature: User Login
Scenario: Successful login
Given a registered user
When the user enters valid credentials
Then the user should be logged in successfully
- Implement step definitions in a Python file (e.g.,
steps.py
):
from kiwi import step
@step("a registered user")
def step_registered_user(context):
# Implementation
@step("the user enters valid credentials")
def step_enter_valid_credentials(context):
# Implementation
@step("the user should be logged in successfully")
def step_logged_in_successfully(context):
# Implementation
- Run the tests:
kiwi run features/
Competitor Comparisons
A home for issues that are common to multiple cucumber repositories
Pros of Common
- More mature and widely adopted project with a larger community
- Supports multiple programming languages, offering greater flexibility
- Extensive documentation and resources available for users
Cons of Common
- Can be more complex to set up and configure for simple projects
- May have a steeper learning curve for beginners
- Potentially slower execution due to its cross-language support
Code Comparison
Cucumber Common (Ruby):
Given("I have {int} cucumbers in my belly") do |count|
@belly = []
count.times { @belly << 'cucumber' }
end
Kiwi (Python):
@given("I have {int:count} cucumbers in my belly")
def step_impl(context, count):
context.belly = ['cucumber'] * count
Both frameworks use similar syntax for defining step definitions, but Kiwi's implementation is more concise and Pythonic. Common supports multiple languages, while Kiwi is Python-specific, which can lead to simpler setup and potentially faster execution for Python projects.
BDD, Python style.
Pros of Behave
- More mature and widely adopted in the Python community
- Extensive documentation and community support
- Supports multiple output formats (e.g., JSON, JUnit XML)
Cons of Behave
- Steeper learning curve for beginners
- Less flexibility in test organization and structure
- Requires more boilerplate code for complex scenarios
Code Comparison
Behave:
from behave import given, when, then
@given('we have behave installed')
def step_impl(context):
pass
@when('we implement a test')
def step_impl(context):
assert True is not False
@then('behave will test it for us!')
def step_impl(context):
assert context.failed is False
Kiwi:
from kiwi import scenario, step
@scenario('Feature: Basic Test')
def test_basic():
step('Given we have Kiwi installed')
step('When we implement a test')
step('Then Kiwi will test it for us!')
@step('we have Kiwi installed')
def step_impl():
pass
@step('we implement a test')
def step_impl():
assert True is not False
@step('Kiwi will test it for us!')
def step_impl():
assert True
BDD library for the pytest runner
Pros of pytest-bdd
- Seamless integration with pytest, leveraging its powerful features and ecosystem
- Supports both imperative and declarative styles of BDD
- Allows for more flexible step definitions and reusability
Cons of pytest-bdd
- Steeper learning curve for those unfamiliar with pytest
- Less intuitive syntax for non-technical stakeholders
- Limited built-in reporting capabilities compared to Kiwi
Code Comparison
pytest-bdd:
@scenario('features/login.feature', 'Successful login')
def test_successful_login():
pass
@given('I am on the login page')
def login_page(browser):
browser.get('/login')
@when('I enter valid credentials')
def enter_credentials(browser):
browser.find_element_by_id('username').send_keys('user')
browser.find_element_by_id('password').send_keys('pass')
Kiwi:
class LoginTest(TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
@scenario('Successful login')
def test_successful_login(self):
Given('I am on the login page')
When('I enter valid credentials')
Then('I should be logged in')
@step('I am on the login page')
def go_to_login_page(self):
self.browser.get('/login')
Both frameworks offer BDD-style testing, but pytest-bdd integrates more closely with pytest, while Kiwi provides a more self-contained approach. pytest-bdd's syntax is more Python-centric, whereas Kiwi aims for a more natural language feel in its test definitions.
The Enterprise-ready testing and specification framework.
Pros of Spock
- Powerful and expressive testing DSL specifically designed for behavior-driven development (BDD)
- Seamless integration with Java and Groovy ecosystems, allowing for mixed-language projects
- Built-in mocking and stubbing capabilities without additional libraries
Cons of Spock
- Steeper learning curve for developers unfamiliar with Groovy syntax
- Limited IDE support compared to pure Java testing frameworks
- Potential performance overhead due to Groovy runtime
Code Comparison
Spock:
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
where:
name | length
"Spock" | 5
"Kirk" | 4
"Scotty" | 6
}
Kiwi:
@scenario
def test_length_of_names():
given.name = "Spock"
then.name.length == 5
given.name = "Kirk"
then.name.length == 4
given.name = "Scotty"
then.name.length == 6
Both frameworks offer BDD-style testing, but Spock's syntax is more concise and expressive, leveraging Groovy's features. Kiwi uses a more traditional Python approach with decorators and assertions. Spock's table-driven testing is particularly powerful for data-driven scenarios, while Kiwi relies on multiple given-then blocks for similar functionality.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Kiwi: Simple BDD for iOS
Kiwi is a Behavior Driven Development library for iOS development. The goal is to provide a BDD library that is exquisitely simple to setup and use.
Why?
The idea behind Kiwi is to have tests that are more readable than what is possible with the bundled test framework.
Tests (or rather specs) are written in Objective-C and run within the comfort of Xcode to provide a test environment that is as unobtrusive and seamless as possible in terms of running tests and error reporting.
Specs look like this:
describe(@"Team", ^{
context(@"when newly created", ^{
it(@"has a name", ^{
id team = [Team team];
[[team.name should] equal:@"Black Hawks"];
});
it(@"has 11 players", ^{
id team = [Team team];
[[[team should] have:11] players];
});
});
});
Documentation
The Kiwi Wiki is the official documentation source.
Getting it
To install via CocoaPods, add this to your Podfile
:
pod "Kiwi"
Or via Carthage, add this to Cartfile.private
:
github "kiwi-bdd/Kiwi"
Support
For all the questions / suggestions you have, that aren't bug reports please use our Google Group
Top Related Projects
A home for issues that are common to multiple cucumber repositories
BDD, Python style.
BDD library for the pytest runner
The Enterprise-ready testing and specification framework.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot