Pytest-BDD Automation Script Development

Pytest is a famous framework for automation, especially with its BDD plugin.

Share your experiences.

1 Like

You mean pytest-bdd · PyPI , which drives under gerkin. Sorry don’t have experience. I use a pyunittest more often for private codes, and a pytest “hybrid/fork” framework in my day job. Gerkin has gotten some bad rep with people around me, so never looked much at it.

Thanks, Braam for replying!

I have explored Pytest-BDD and found that it has several limitations and we need to develop many core functionalities which do not exist.

It’s good but at the same time, it’s time-consuming.

That was my same issue with pytest itself Vivek. After we had requirements for new test fixtures to handle remote “nodes”, we ended up modifying so much of pytest that our fork of it is unrecognizable. We added more decorators to handle the syntactic sugar we needed around test cases, but I think so much “teardown” fixture work needed adding, because we were finding we needed to ensure that even if the test tool crashed, that we still needed to deal with open connections to remote computers in a test need forcing closed. The same kind of problem with setup() fixtures that need to make remote (pyrpc) connections when a test starts, was a big pain. Now that many of us are stuck working remotely some of the RPC code that was mostly platform-agnostic is now not terribly network-agnostic enough. It never ends.

I have used a Framework with a DSL language, (we actually wrote our own one) but my experience is that you should only move to a DSL when you are forced to by test suite scale problems. Coding in one language is hard, coding in 2 makes debugging much harder. The problem is that nobody ends up having enough time to write tests for the DSL fixtures themselves. You have to test your own tests. I say this because as the test toolstack changes, you need a robust self-test of the stack.

This will probably mean you spend 20% of your time fixing self-tests on the toolstack itself every time you add helpers or fixtures, and 80% of the time writing product tests. But I am a fan of TDD, so writing tests for my test code is pretty nice to be able to do a tiny bit of.

1 Like