00:00:06.090
hello yeah good morning everyone so today I'll be talking about BDD with
00:00:13.740
cucumber so a little background of me so angry
00:00:21.470
it's easier to remember if you know like graphical user interface that sounds the
00:00:26.550
same so in like normal lectures when they talk about that and like seems that
00:00:33.090
I've been called I'm a software engineering on app and I work with Java
00:00:40.199
Python and wah so Java as a meter and fightin as the server-side configuration
00:00:46.890
and all sold wha for engine X and Ruby so yeah I'm also an active member of
00:00:55.760
geography Bill Gates and I do a lot of volunteering jobs not jobs volunteering
00:01:03.589
events for real skills and also reach out to universities helping to growth
00:01:11.250
Alan's in Malaysia so a background my company so our company does cloud
00:01:18.810
infrastructures so we do VMs DNS CDN cloud storage disaster recovery so we
00:01:27.299
are like a b2b service where we sell all the cloud infrastructures to our clients
00:01:32.430
to compete with someone like AWS and so our office is doing the CDN portion so
00:01:41.640
we have like 170 plus location worldwide
00:01:46.970
our job mostly is maintaining ages and also parallel service we'll have like
00:01:53.220
video streaming file caching like images CSS JavaScript and live streaming so
00:02:01.610
that's about it so let's talk about what you expect for this talk so you know
00:02:08.399
about what is BDD after this talk of introduction to cucumber and also how
00:02:15.420
our company on app using cucumber so first well it's BDD so BDD is a
00:02:25.660
synthesis and refinement of practice stemming from TDD and a TDD so what is
00:02:34.320
80 DB so 80 DB is a certain test-driven development which have been used mainly
00:02:43.090
for product design so when you have product design you have like this kind
00:02:48.820
of process where you have three different hats so you will have a person
00:02:54.100
a group of person people that represent customer a group of people that represents development and testing so
00:03:01.750
all three groups of people will work together to come up with exceptin has
00:03:08.410
the requirements for the feature and its also represent the user point of view
00:03:15.460
and act as a point as a form of requirements that describe how the system should function in some cases we
00:03:25.660
also are the T most ultimate the acceptance test so next is test-driven
00:03:33.220
government GDD that's the common stuff in like Ruby community so test-driven
00:03:40.960
development refers to a style of programming which consists of three main activities which is coding testing and
00:03:48.160
design so first we will write unit tests then we run the even test so write a
00:03:55.750
minimal behavior that you expect to behave on your feature and then write
00:04:03.580
your code so this code is mainly to pass unit tests because you are trying to
00:04:10.340
produce some behavior that you expected and then refactor make sure your code is
00:04:17.449
clean and it can be maintained for long term while passing the unit test and
00:04:23.229
then you repeat the process all together okay so next so this is the BDD tactics
00:04:35.320
for practicing BDD so first use the
00:04:41.900
story so you apply the five wise principle to each proposed user story so
00:04:47.330
that the purpose is clearly related to business outcomes so five wise as in
00:04:52.450
wh-why so I ask the question why four five times why do you need this and then
00:04:59.150
why continuing asking why we'll make it very clear that what your features is
00:05:05.630
about and also next thing is behavior that consider behavior that contribute
00:05:12.470
the most so thinking from the outside in you will implement that the features
00:05:19.729
that's more resonance to the client so you don't create stuff that your client
00:05:26.030
doesn't need and then the next thing is to describe in single notation this is very important because when you design
00:05:33.950
certain stuff right you design a feature where certain keywords are very specific
00:05:42.050
for for programmers and it's not understandable by designers so to make
00:05:47.840
sure that everyone in the same page do use the single notation to translate and
00:05:53.479
also express your features so that every single one in the different group of
00:05:59.360
your team understand what you're talking about not using specialized keywords
00:06:05.650
because no one will understand that and then applying this technique all the
00:06:11.950
way down to the lowest levels of abstraction of the software and paying
00:06:18.330
attention to the distribution of the behavior because you were easy for you
00:06:24.910
to maintain or change if you really understand what the system all about so do understand the behavior that you
00:06:32.620
stret spread around until the lowest level to recap so BDD is to help create
00:06:43.230
understanding of the business requirement and also help to design the
00:06:49.960
feature and also serve as documentation and taste test cases so go school Asik
00:06:59.320
is one of the prominent figure in agile and software the woman she described
00:07:05.230
BDDs specification by example so he also
00:07:10.330
wrote two books which is impact mapping and also by the title specification by
00:07:16.960
example so to practice this lets consists of two activities the three
00:07:23.140
amigos this is the first activities where you have a specific Gatien
00:07:28.750
workshop so first you will have the project for that manager which will
00:07:35.380
describe the user needs in the user side was the story so you have a requirements
00:07:42.160
user behavior what customer wanted and the next thing is the developer so the
00:07:49.480
developer will also raise concerns on how to implement what is technology how to maintain what the infrastructure
00:07:54.820
that's needed all the stuff and then X is tester Assessor will be some question
00:08:01.630
on whether this feature is feasible not really feasible how to test it what H
00:08:09.310
guess cases that is not being considered so people in charge of defining the
00:08:17.050
requirements which is the product we'll sit down with all these programmers and also testers to discuss
00:08:26.830
the feature to be implemented and then they come up with examples on how the software should behave and write down as
00:08:33.669
a cucumber scenario so during this phase
00:08:39.910
the workshop the most commonly used practice is example mapping so example
00:08:48.610
mapping will took like 35 minutes and then there's different colors the first
00:08:54.160
colors yellow will show the story and then rules example and also if you have
00:09:01.210
questions during the example mapping you can put on the right side so you don't
00:09:07.720
forget about it because questions are important and when you design certain feature you have question before better
00:09:13.720
about it then that's a bad thing so remember you have questions you put on the right side so you need to settle it
00:09:19.570
and then this will help you to zoom in and focus on the smallest piece of
00:09:25.750
behavior inside sorry and also tease
00:09:30.790
apart the rules find the core of the behavior that you want and defer the
00:09:35.800
rest until later means you don't want your story to be too big you'd want to implement everything in one shot you
00:09:42.280
want to break down in smaller pieces so if you find your stories to be you can break it down even smaller it's more
00:09:49.000
easier that way and with this scrutiny example and the mapping act as a filter
00:09:56.590
so it prevents a fad story from getting through a sprint and exploit during last
00:10:02.830
minute you don't want that so here are the comparison of scenario
00:10:09.860
just now we mentioned about cucumber scenarios so a scenario is an example of
00:10:15.980
the system behavior from one or more user perspective so this see now is example from the user
00:10:22.579
side okay except in test sorry acceptance criteria accepting criterias
00:10:28.790
are a set of rules which covers aspect of the system behavior and from wishing scenarios can be derived so accepting
00:10:36.259
test is a set of rules from the system so you can give example with scenario
00:10:42.910
for your different criteria that's the difference when it's rules or exact
00:10:48.110
example okay during workshop you will need to make a
00:10:54.649
decision in the end right so you need voting so commonly used voting is rumen
00:11:00.079
voting which you have the light button or the lights thumbs up and thumbs up
00:11:05.929
means I support the proposal sideways sideways means I go along with the wheel
00:11:14.299
of the group means of no go man and either agree or disagree I'll go with
00:11:19.459
the group and then thumbs down I don't agree and I would like to speak so if you have a mixing area where you
00:11:28.189
have a thumbs down and O's some thumbs up you need to further discuss on what can
00:11:34.850
be explained or clarify so that everyone
00:11:39.980
reaches the common consensus so if you still have it comes down make that
00:11:44.989
resolve so everyone should either have a thumbs up or sideways to reach a
00:11:50.149
consensus okay the second activities of the
00:11:55.700
specification by example is outside in development by programmers so let's
00:12:01.010
stick this example so you have Google you want to search something you search
00:12:06.020
for timer for like one hour it should show something like that so for this
00:12:14.630
activities you start with the functionality that closest to the user the user interface which is on the
00:12:21.140
outside of the system so you focus on what is closest to the user rather than directly go to the system itself and you
00:12:28.340
gradually work towards the guts of the system business logic persistence messaging and so on as they discover
00:12:36.410
more what's to be implemented so if you look at the user point of view you
00:12:43.370
understand more how user works in your features rather than directly jump into doing the stopwatch logic doesn't make
00:12:50.450
sense like with it really use that so
00:12:56.470
now we are going for cucumber so that's the picture when my team first which
00:13:04.090
given a task on cucumber it's very scary right so yeah cucumber is a behavior driven
00:13:11.330
development it's um the string of cucumber and it's written in Ruby a and
00:13:18.610
uses gherkin is the SL language the
00:13:23.630
domain language for like Ruby Ruby cucumber so you need to write in certain
00:13:28.910
language in order to parse commonly used for design documentation and regressions
00:13:37.060
kay so a note for everyone
00:13:42.960
cucumber is not a testing tool so if you want to use cucumber as testing tool is
00:13:48.450
not so this is why so the creator of cucumber says that if you think you can
00:13:55.590
brace the testing tool please read on because you are wrong cucumber was born out of frustration with ambiguous requirements and
00:14:02.370
misunderstanding between people who ordered the software and those who
00:14:07.470
deliver it because there's a miscommunication between the requirements and the person who designed
00:14:13.290
it that's cucumber came into place it's not a testing tool testing tool is to test
00:14:18.330
whatever you write or before you write in the system way this is from end to
00:14:24.030
end starting from user until the system so gherkin let's talk about gherkin it
00:14:34.440
also mean pickle cucumber those you found in burgers but it's not that it's
00:14:40.320
a business readable language is in pure English or any language in a smoke like
00:14:47.400
French Malay Chinese you can do whatever language you want and this is
00:14:54.720
domain-specific languages DSL so they have certain format to do that it's business readable and somewhat
00:15:02.210
conversational and very specific logic it's help you do it Express features in
00:15:09.750
natural language it uses given when and then so just like experiment where you
00:15:17.430
prepare you execute and you observe all very fine it's available in 60 languages
00:15:24.540
so whatever language that you use can use number whoever designed the feature
00:15:31.290
whoever your program manager is they can write cucumber so this is a Malay so you
00:15:40.530
can write actually write a Malay cucumber scenario and it works
00:15:47.610
later we'll get to this in demo okay
00:15:52.770
okay let me explain about a gherkin in the feature files so all cucumber
00:15:58.660
scenario end up with not feature extension and then so use the example
00:16:04.090
just now the Google search you have feature timer countdown in such result so this is a broad explanation on what
00:16:13.150
the feature is about and then the scenario is the example that you want to try so it's user able to see the timer
00:16:19.300
when switching it and then given that user Adam open the website Google when
00:16:26.560
he types timer for one hour then he presses the button search then he able to see a timer and that means counting
00:16:34.330
now from one hour so the green color that face feature so what is the feature
00:16:39.580
feature is a bigger picture of what is the feature this scenario is the test
00:16:47.080
case or behavior I use use user experience so is you look at it as a
00:16:56.110
user site of using your feature given so
00:17:02.050
it's a set up precondition when it's action and then then is to verify the
00:17:11.170
outcome okay so we extend we expand a
00:17:17.410
feature phone now we have backgrounds so background we have like given a user Adam when he opens the Chrome browser
00:17:23.290
then he able to see the search bar what does a background in a cucumber wow this background is to set up States
00:17:33.010
and condition before running any scenarios and it runs as a before hook
00:17:38.200
so for every single scenario you have a background we run first so you can write
00:17:43.720
other scenarios it will still run the background so you can write some
00:17:49.140
preconditions before example your example or the scenario runs
00:17:54.890
okay so the recolor one you can see given a username Adam this will need a
00:18:03.230
step definition to actually use it so from here you can see given a entity
00:18:09.380
name do entity name so you extract the values of entity a name you load from a
00:18:16.760
fixtures and then you will see whether the features is already exist if it's
00:18:22.250
not exist you create the entity so you need to do some process or Ruby
00:18:31.340
functions to make sure all your entities are well setup and this is called step
00:18:38.540
definition okay okay additional glossary
00:18:45.410
so we all have hooks just now I mentioned about before hooks in cucumber we have before and after hooks this is
00:18:52.610
part of the configuration so if you see after cucumber so you can help you come
00:18:58.970
but you quit if you find any errors you can set up so it won't continue to run
00:19:05.630
if you set the configuration to tool and then it'll also allows tag hooks so if
00:19:13.880
you use add something this is called attack so you can run impact also you can use wherever this hook is been
00:19:20.990
identified do certain stuff so this is also part of the configuration remember
00:19:27.370
maintainable cucumber first you need a feature file next you have a step
00:19:34.910
definition and then you have help across helper folder so this tree are the main
00:19:42.260
components to write cucumber so you need a feature of our step definition to help
00:19:48.350
us and then features and hooks or configuration those are optional this is
00:19:55.070
to make sure that you all have your cucumber more feature more running more
00:20:02.450
smoothly and do some tricks on the scenario so
00:20:07.910
let's see whether I can get something
00:20:15.120
it's not
00:20:21.119
right here so need to show you something on the comer
00:20:36.250
so how we used to compare in our normal
00:20:42.870
book is
00:20:56.720
you
00:21:06.060
okay hmm so you can see our structures
00:21:11.120
from here we have features and then inside features we'll have like step
00:21:16.980
definition and support supports is all the features and helper class and also some configuration this is how we set up
00:21:25.550
for Humber let's go back to slides
00:21:32.100
okay so that's one conference called Chuck in UK where it talks about BDD and
00:21:41.039
also agile ramen in cucumber so that's one saying that you need to keep your
00:21:47.880
step definition clean so you can use help class and variables to prevent you
00:21:55.110
from calling a step and another step so you have like creating a web block then
00:22:02.940
you have when I create a web block you will call create a web block step you
00:22:08.730
don't do that because you deprecates very soon this practice will couple all your step
00:22:15.090
definition together which will make your dependency very tightly coupled when
00:22:20.400
something changed you'll break a lot of stuff so we advise that people to use classes to replace step calling steps so
00:22:28.770
that's the link for the come the for the conference so how we make use of
00:22:34.710
cucumber in our company so first we drop a user sorry
00:22:40.159
according to Turkey that's our product manager doing that and then we write
00:22:48.500
number scenarios before and during development so it's like TDD we write
00:22:54.720
the scenario first run it and make sure everything is in place and it fails and
00:23:01.799
then we create the software and also build the software to make the test pass
00:23:10.070
and also this is the thing run cucumber against your development branch and also
00:23:15.330
on in build servers so when we push to like our build servers Jenkins we will
00:23:20.940
run a process of cucumber it will validate all our software whether it's
00:23:28.200
it breaks or there's any changes in behavior so that is serving as a regression so we
00:23:38.100
will know whether our new features will break the current existing behavior so
00:23:47.690
let's talk about my experience with cucumber so that's good things and bad things about cucumber when you work on
00:23:54.990
it so the bad things the Convention and
00:24:00.000
also maintenance it's very hard to set a tone in writing a cucumber because you
00:24:06.750
need to write in a certain way so that everyone can on board easily and also
00:24:12.030
people are like in the future you're writing arrows much more easier so let's
00:24:19.140
take a sample of what we have now okay
00:24:25.710
so you can see this scenario is very nicely formatted it's not one or two
00:24:32.250
days work to set this convention you need to know what you're doing you need
00:24:37.500
to know how to make it modular so if you write like just normal English you will
00:24:44.670
reach these states because every person writes sentences are different you don't
00:24:52.260
want to step support all those cut type of ways of writing English you'll be
00:24:58.470
held in writing your step definition and then this is also a pin point to
00:25:05.160
maintain a cucumber because every single time a new feature come up there's a new
00:25:10.590
sentence a new type of behavior that want to support so it's kind of painful
00:25:17.280
to do that so let's move on the good
00:25:23.400
thing is about cucumber documentation and regression so do you like to update
00:25:30.420
your documentation every single time you change something like everywhere if you
00:25:36.480
have written one of the stuff and then you have version 2 version fee
00:25:41.929
or you make a small tweak in certain component and it changes other stuff do you want to update all the document that
00:25:48.440
relates to it or you just want a single place of truth cucumber so that's what
00:25:55.159
we see as a very good in very good method to do that so as business people
00:26:03.529
don't have to ask us what is the behavior offices and stuff just read cucumber versus English you understand
00:26:09.889
English it's easier don't have to ask everyone to verify certain stuff and
00:26:15.259
also regression so in the future if you add features you make sure existing stuff doesn't break this stuff as
00:26:22.240
regression checks so why should you use it when you bring some new features is
00:26:30.409
very cheap right in English in gherkin rather than writing a code base and then
00:26:37.759
throwing out you just you need to understand what you are trying to build so write in English in gherkin format
00:26:46.090
and if you are hitting constant problem and configuring drama across teams so
00:26:52.369
you have like a designer team then they pass to a programmers then they pass the designer the designer finally the
00:26:58.940
programmer this is not what this word meant because there's no clear communication you just the product
00:27:05.779
designer just through the docs to you and then programmer things that's what it means there's no communication
00:27:12.289
there's no coherence on understanding the single notation so you want to come
00:27:19.580
back to do that you need a single point of truth it's very important and you don't to update
00:27:26.539
documentation when all features being changed so why do you company probably
00:27:32.690
not for you if you are building a features that very very clear
00:27:38.240
instructions you don't need to remember is a lot of process designing feature
00:27:43.369
that doesn't involve everyone so you only involve one parties then maybe not
00:27:48.830
suitable for YouTube or you just want a testing framework this again this is not a testing
00:27:54.600
framework if you want a testing framework go for capybara or r-spec that's more the or suitable framework
00:28:03.630
for you and we are moving some of our cucumbers in area into our spec because we think that we are more comfortable in
00:28:11.840
doing it in r-spec but we still maintain some of the stuff in the cucumber
00:28:17.330
company does uses cucumber so we have platform paper and also Groupon to
00:28:24.890
confess so this is a conference of BDD
00:28:31.140
it's in UK so you can go to that link if
00:28:36.510
you want to know more and this are the reference that you can get if you want
00:28:43.200
to know more about cucumber is in github is open source and let's see yeah
00:28:51.510
granny so the slides will be in here and I found that a lot of people - shows
00:28:57.270
allow cat pictures so we have our office cats do have a Facebook page
00:29:06.850
our employees do that so we have yeah we have a page for them so if you want to
00:29:13.450
go to dig in you know it's actually our office cat yeah so let's see whether we
00:29:22.210
can do a quick demo just I'm promise ah lights is bad can you see the orange the
00:29:31.000
yellow color links
00:29:46.320
they better know okay so what I'm trying to show here is running cucumber in
00:29:53.789
Malay language because as I mentioned right you can use sixty language to write your cucumber scenarios so this is
00:30:01.889
the Malay so to run it you just type cucumber and then your feature name and
00:30:09.120
then just run so it says that let's see make it bigger this is that your step
00:30:19.350
definition haven't been implemented so the first time you run you write your
00:30:24.450
cucumber scenario you get this you say that you're setting a feature is not implemented yet so let's go to the step
00:30:31.769
definition
00:30:37.590
kay well this was
00:30:46.960
okay so you just copy everything in and
00:30:53.830
comment this out
00:31:14.710
and then you try to run it again
00:31:27.250
and again so yeah you can see that after you copy to step definition you will say
00:31:33.970
pending because you they will have a pending were in comments here you can
00:31:40.480
see there's a pending here to prevent you from not writing it if you just
00:31:46.060
plainly copy it won't pass thought minnows maximize the
00:31:58.280
so if we do this we just comment out the
00:32:03.980
pending because you for here you should write your cucumber helper class and
00:32:11.170
call in your helper class to do stuff for you
00:32:21.870
hmm whew
00:32:29.190
all of them in all like
00:32:36.929
so now yeah it passes so you need to write certain stuff in the step
00:32:42.550
definition in order to pass so this is how it works and then the color is not
00:32:52.600
there so you can see it runs of each of us at the step definition what's the line number is running so
00:32:58.000
this will help you also to understand what you are doing okay that's it for me
00:33:03.750
any question all right thank you so much great thank you for speaking about this
00:33:14.470
thing still won't do it joke all right I did questions on testing strategies BDD
00:33:21.640
TDD whatever you'd like to ask sure great
00:33:31.520
hello oh yeah yeah so because cucumber is used mostly as a documentation tool
00:33:37.140
and a regression - not as a testing framework so how it is possible to share
00:33:44.130
the documentation that you write using cucumber with non-programmer people
00:33:49.770
because normally I see it's inside the code base itself so it could be not
00:33:55.650
accessible so do you have any idea how we can do that so cucumber meant for a
00:34:02.040
single point of truth so yes it's correct it will be in a git
00:34:08.040
repository so to allow people to see it we will need to give access to the
00:34:15.150
business people and we introduce how to write gherkin for them so they can write
00:34:22.410
on the Google Doc for us our product manager will write on the Google Doc and then we will translate into our gherkin
00:34:31.710
format because we want to make it maintainable whatever product manager
00:34:37.110
will do you place some pictures on the wireframe so we need to translate it so
00:34:43.590
this extra boat for us but you will find a way to a middle ground where you can
00:34:49.800
work with a product manager to find a way where it works best for a team so different teams have different needs
00:34:55.670
it's just need to find a way to work around that okay thank you so there's no
00:35:01.980
way to visualize it at all from Y no no that's no visualise it's a project
00:35:07.650
available for anybody any other questions
00:35:18.040
so my program manager previously is a like our part of our programmers
00:35:23.900
actually and then he he doesn't do much development after he moved up to
00:35:30.890
remeasure so um to make product manager understand gherkin is like doing act
00:35:37.660
experiments so you have a three key words given when and then so ask them to
00:35:44.180
follow these three rules given that some condition when you do an action then
00:35:51.740
what you should see so it's easier for them to understand if you have like these three words and using these three
00:35:58.400
words you can translate into scenario it's very sufficient for that already
00:36:06.010
for now no we just use it plainly right yeah any last questions
00:36:16.650
nope never tied alex is shaking he says I'm alright there are no questions thank