Member-only story
BDD Like Widget Testing
This is a real easy way to get BDD like widget tests without having to learn the Cucumber-Gherkin languages. And it runs on unit testing and so much faster in executing as tests then on the emulator.
Installing eBay’s Given When Then Library
Golden Toolkit is not the only useful testing library from eBay, as the Given When Then library sets about to lift-up the testing predicates into testing harness constructs that allow semantic naming of harnesses and methods to bring semantic-BDD to widget unit testing.
To install it in the pubspec:
dev_dependencies: given_when_then: ^0.2.0
Now we have to implement a test harness per each BDD use case.
Implementing The Counter Test Harness
I am using the same code from a previous article, which is in the goldentoolkit_notintl subfolder:
https://github.com/fredgrott/code_with_me/tree/master/cookbook/goldentoolkit_notintl
eBay shows a mock of a harness rather than an example testing a sample app which is hard to understand for those new to flutter. Here is my counter example: