BDD uses natural language to describe the "desired behaviour" of the system, that can be understood by both the developer and the customer
Demo of an existing BDD application using Godog predominantly used with golang
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
BDD Testing Using Godog - Bangalore Golang Meetup # 32
1. Using Godog for writing
human readable tests
@gkGaneshR @openebs
2.
3. Introduction
What is Test Driven Development (TDD)?
Problems with TDD?
Desired "behavior" of an system is specified in terms of code, not always the right
way to capture behavior
Other stakeholders in Software lifecycle find it hard to be involved in the whole
process
4. Unit testing is a component of Test Driven
Development
// hello_test.go
package main
import "testing"
func TestHello(t *testing.T) {
got := Hello()
want := "Hello, world"
if got != want {
t.Errorf("got '%s' want '%s'", got, want)
}
}
// hello.go
package main
import "fmt"
func Hello() string {
return "Hello, world"
}
func main() {
fmt.Println(Hello())
}
5. Introduction
What is Behaviour Driven Development (BDD)?
● BDD is TDD done right!!!
● BDD uses natural language to describe the "desired behavior" of the system,
that can be understood by both the developer and the customer
● Demo of an existing BDD application using Godog predominantly used with
golang
6.
7. Need for BDD
Automatically generate test code from "behavior" description, eliminating the
intermediate step of writing test code.
This allows the direct execution of "behaviors" on application code.
Godog makes BDD available to the developer community, by reducing the
learning curve, time and effort
8. Need for BDD
In existing BDD frameworks, developer needs to manually write the glue code
which maps "behaviors" to the implementation code
This mapping involves writing code for interpreting behaviors in terms of
test-cases
Writing this glue code is tedious and error prone, if the written test code does not
depict the specified behavior
Can this intermediate step of writing glue code be automated?
9. Syntax
GIVEN, an initial context
WHEN, occurrence of an event
THEN, expected outcome
Parameters in Quotes, " "
Connectives - And and Not (only in then condition)
10. Example
Scenario 1: Account Deposit
Given a bank account with a balance of "100" $
When a customer deposits "20" $
Then the balance of the account should be "120" $
11. Demo : Create a virtual cStorPool on disk
Feature: create cStorPools
In order to store data efficiently
As a devops admin
I need to be able to create cStorPools
Scenario: create 1 out of 2
Given there are 2 cStorPool requests
When I create 1
Then there should be 1 remaining
12. openebs/litmus
Litmus is all about kubernetizing godog
It is all about how the software is going to be presented to end user.
End user can debug by running test cases written in language he can understand.
Litmus bridges two world : kubernetes and user
Litmus is generic that can be extended for your application if plugged onto k8s.
Mapping between user stories and corresponding backend api is done via
matching string, which is currently supported.
13. Litmus feature requests - plans
Have some generic plugins along with user stories.
Auto debug of k8s-failure
Chaos engineering - induce failure and check
Instead of developers coding function with user stories, apply simple yaml
files(using kubernetes CRD)
16. Natural Language Processing
● Language Augmentation
● Prioritizing/weighting words: based on Part of Speech (POS), e.g., verb, noun, adjective
● Filtering out unimportant words, e.g.,"a", "the", "is"
● Clarifying language meaning using:
● Synonyms
● Stemming
● Grammatical structure
● Using: openNLP, StanfordNLP, WordNet, Snowball
17. NLP Augmentation engine
● Make inference about order of parameters that are passed.
● Augment with root words and synonyms.
● Make as much inference as possible.
Reference:
Godog
Cucumber
smartBDD-trying out NLP in java, it seems
18. OpenEBS Hackfest
Each Contributor will get an OpenEBS Hackfest Special edition T-Shirt
Every Week 2 best PR's will get Programming book of their choice
The Best PR of Hackfest can win a laptop
19. THANKS FOR THE PATIENCE !!
Contributors are welcomed !! https://github.com/openebs/litmus
Support and Follow us @gkGaneshR and @openebs