Open KarthikRIyer opened 2 years ago
I’ve long been a fan of pytest and would support us switching over. It seems to have pretty wide adoption at this point and I think it would provide some tools that would simplify a lot of our test code.
While BDD testing in Spock is pretty elegant, the BDD solutions for python feel to me like they’d be heavy to maintain. Every test requires keeping two files in sync with one another and there is a lot of boilerplate (in separate functions with specific decorators) required to implement them.
My vote at the moment would be to migrate to pytest, but defer on BDD unless a more elegant solution shows up.
The thumbsup from @apetrynet also reminded me, when he created the plugin template, we accepted pytest into the otio ecosystem in a subtle way. So there is some precedent and example of how we can integrate pytest.
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, 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:
And the code in groovy would be like:
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). The most popular and powerful seems to be behave. There's also 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 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