AcademySoftwareFoundation / AcademySoftwareFoundation/OpenTimelineIO

BDD Testing

Open
#1,228 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2k
Forks
351
Avg merge
1d 12h
Merged PRs (30d)
1

Description

## Feature Request

Proposal to add BDD (Behaviour Driven Development) tests to the project.

## Description

I'm thinking of migrating to BDD tests in the Java bindings using [spock](https://spockframework.org/), a groovy framework. I thought it might be helpful to do the same for the python tests.

The idea of BDD testing is to write tests in a simple user/business friendly manner. The tests become a documentation in themselves. For example:

If we want to write a simple test to see if disabling an Item works...

The BDD specification would be like:

```feature
given: "An item is created"
when: "Item is disabled"
then: "Item does not contribute to the composition"
```

And the code in groovy would be like:
```groovy
given: "An item is created"
def item = new Item()
verify {
item.enabled() == true
}

when: "Item is disabled"
item.setEnabled(false)

then: "Item does not contribute to the composition"
verifyAll {
item.isEnabled() == false
}
```

It might be a lot of effort in the beginning but once you get used to it, it becomes simpler and clearer. It'll also be helpful to community members new to the project. The current tests might not be very clear to them.

There are a couple of BDD testing frameworks in python ([framework comparison](https://automationpanda.com/2019/04/02/python-bdd-framework-comparison/)). The most popular and powerful seems to be [behave](https://behave.readthedocs.io/en/stable/). There's also [pytest-bdd](https://pypi.org/project/pytest-bdd/) which is compatible with pytest. Does anybody have an opinion or idea on what could be used? I tried using behave and [implemented](https://github.com/KarthikRIyer/behave-tut) a tutorial. Seems simple enough.

Any thought on taking this forward? Or should we continue writing unit test as we do right now?

## Context

Here's the Java bindings PR where I discussed with Eric about this: [#57](https://github.com/OpenTimelineIO/OpenTimelineIO-Java-Bindings/pull/57)

Contributor guide

Open the contributing guide

Research direction

No project files or specific tests are named. Start by reading the Java bindings discussion in PR #57 and reviewing the existing Python unit-test approach, then compare behave and pytest-bdd; the work would need a decided framework and an agreed migration scope before implementation can be considered complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java, python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.