welcome depending B has benefits a lot
of coding adventure everyone I'm Steve
perch lead developer advocate at
Pantheon you can find me as Steve vector
on github drupal.org wordpress.org
Twitter just about everywhere if you
ever need to email me Steve that Hirsch
at Pantheon dot IO I'm always happy to
come back to Chicago I lived in Chicago
for about a decade in college and after
college as always it's always fun for me
to be back here and and for the purposes
of this presentation we're going to
pretend in my job at Pantheon I'm not in
the world of day-to-day site building
but that's where I spent most of my
career I spent most of my career making
Drupal and WordPress websites me and the
Drupal sites and one of the things I was
interested in in my time building sites
was how can I test these sites I make
sure that they are functioning well so
for much of this presentation I'll be
switching between two modes that the
Steve you see before you who were accept
Pantheon and the hypothetical will call
him Stephen who whos mcing at that
agency world building sites all the time
and in that in that hypothetical world
the site that Stephen is working on is
the umami magazine website who who here
has seen this website some people in the
back great so this is a brand new
feature in Drupal 8.5 one of the
challenges with Drupal itself is how do
you show people what Drupal can do out
of the box so this is a new set of demo
content a demo profile demo theme built
into Drupal 8.5 so if you ever need to
show a potential client what can Drupal
do out of the box it can do this for you
I should clarify I was not at all
involved in the in the contribution of
the umami profile and theme to a Drupal
hypothetical Steven who's in the agency
world building umami magazine for a
client he wasn't involved in the initial
site creation
he's coming into this project right at
the end as the project is getting close
to lunch he's just there to finish off a
few features and and get things washed
now
we'll also be talking of course about
behalf here out of curiosity who here
has ever worked with me on I'm just
curious
sensitive all right about half the room
who here has well I'm assuming the other
half haven't worked at the end who has
has never worked with any kind of
automated testing tool whatsoever great
so the thing you need to know about
automated testing this is about the
level of information that the
hypothetical Steven has about automated
testing is that behalf like any
automated testing tool is its own
standalone thing B hat on one level is a
command line application and it can
interact with the Drupal website how
does it interact with the Drupal website
well it separately has a set of
definitions that tell it what the Drupal
site is supposed to do it reads from
those doubt feature files that describe
what is this Drupal site supposed to do
it leaves those expectations and then it
interacts with the Drupal website to to
verify is it is it actually doing that
now that that may sound very vague and
hand-wavy and that's that's fine because
for actual neither the first few years
I've been to about B hat it didn't fully
make sense to me either so I I'm hoping
the idea this presentation is that
mainly through showing it will start to
make more sense last year at Drupal con
I did a similar presentation that was
very conceptual very slight heavy if
that's what you'd like to learn go back
and watch that YouTube video but this
one is going to be much more demo
oriented live coding oriented and I hope
that that will help you learn how all
these pieces fit together so one of the
reasons hypothetical Steven is excited
about using B hat is because it allows
for the automatic execution of tests
over and over and over again what we're
looking at here is a screenshot of one
of the many many ways you can run your
automated tests over and over again
circle CI is a is a tool you can use for
your automated tests over and over again
and it's really satisfying I find to get
those green check boxes they tell you
that your tests are still passing that
is super exciting to me as a developer I
like to get that positive reinforcement
and the clarity of if it's red well then
something is wrong and I need to fix it
so the reason this presentation is
called bending B has benefits is because
I want to highlight two main benefits
that you can get from the AB automation
the ability to run your tests over and
over and over again and clarity a clear
understanding of what your site is
supposed to do so again a hypothetical
Stephen has come on to this
Emami magazine project I've got it
running locally here again this is
basically just vanilla Drupal 8.5 I set
this up one of those 8.5 Release
Candidate one but I've got this Umami
website it has a home page has cool
articles and recipes has pages for just
just the articles pages for just the
recipes you can look at a single article
here so a pretty normal looking Drupal
website but it's nice to have this as a
reference rather than just the standard
profile so the automatic execution side
of things what does that look like what
he has I've jumped over to the command
line here we're using the command line I
can automatically run a behead test and
I'm not expecting all this to make
immediate sentence for this that's fine
Stephen has figured out by it by poking
around the codebase that it is possible
to run your b-hat tests over and over
again so we're just gonna run a single
b-hat test here
and what this b-hat test is is checking
is articles promoted to the homepage so
Steven is is on this project somewhat
alone as a developer the the lead
developer who architected this who set
up these initial tests is no longer on
the project and I don't have day-to-day
access to that developer but I can I can
look at this and I can see all right so
this is articles getting promoted to the
home page in order to control which
articles receive attention as a content
editor I need to promote articles to the
home page
interesting how is house this actually
functioning well Stephen can poke around
the codebase and see that somewhere in
this codebase there's a file called
articles promoted home page and I can
see all right there's this scenario here
I don't fully understand how this is
working but I can see it has this phrase
just given I'm logged in as a user with
the administrator role somehow I don't
fully understand it yet but somehow be
hat is logging into my Drupal site as an
administrator sounds pretty cool and
somehow I don't understand yet B hat is
making a new article titled really
important article marking it as promoted
and then going to the home page and then
checking that really important article
is in the home page promoted article
region so what what that means on on the
real website is this section here this
article here is there because it is a
promoted article so again I don't fully
understand how this is working but it's
intriguing to me as developers come on
to this project I'm tempted to try and
figure it out myself
so let's further pretend let's further
pretend that we are on the daily scrum
call again we're getting close to launch
I've got a backlog of a few tickets that
I'm supposed to be working on but my
client says to me hey do you know that
that sidebar of articles on like the
articles page and I say oh yeah this
this this thing here that the recent
articles thing my client says to me that
was supposed to be related articles I
think to myself oh I didn't know it was
supposed to be related are
cause I just came on to this project and
I think to myself there there was a lead
architect there was a lead designer and
so they had long conversations I know
there are some out-of-date wireframes
out there I don't really want to go back
and like do the project archaeology to
figure out was this really supposed to
be related articles because of the
Drupal cycle right now if my client just
wants related articles by tag so I asked
my client do you just want like these
tags to inform related articles my
classes yeah just use the tag to make
related articles I feel like it's gonna
take me more time to like negotiate
doing this through the proper ticketing
process I'm just gonna say yep we're
gonna do it I'm a Drupal site builder I
can just add one more argument to this
the sidebar and I can turn recent
articles into related articles about
anybody ever been in the position where
it seems like it'll be faster to just do
please then hit open it'll be to talk
about it and like go through what feels
like the proper procedures so that's the
mindset that I mean I'm just gonna do it
just gonna do it it's now - take it but
after strong I'm just gonna go straight
to it get it done so I'm going to go
over to the view that controls that
sidebar now if I were doing this for
real out I would just be going to the
block that is relate our recent articles
and I would add a new filter but
alternate-universe
steve has made things a little bit
easier for me and done that already so
I've got it an alternative block that
already has added this taxonomy term ID
I just want to take the tags that are on
the current node and make it related
articles super simple right all I need
to do is say yeah get the taxonomy term
ideas from the URL if we're on a note
page like you got here load up all of
the taxonomy terms from the node filter
it down to the tags normal views
behavior it's been there I think since
Drupal 6 we've we've had basically this
capability but this is the section that
gives me pause this is the section that
makes me think maybe I should have
talked to my client a little bit more
about what
exactly did they expect do they expect
every single turn to get accounted for
like is this an end query where is this
an ore query I really wish I had asked
my client what exactly do they expect
but I'm in the mindset but I'm just
trying to get this done quickly and I
know this this site so far doesn't have
a lot of real content and in it like my
client is behind on putting all the real
content so I'm concerned that if I do
the all option basically the and query
there I don't think there's a single
other article on this site that is
carrots and vegetarian and healthy so
I'm going to be the over query that just
feels like like the right thing to do
I'm going to do a filter to items that
share any terms reduce duplicates sure
all rights apply I promise I'll get to
the B hat part soon here so I need to
update the block layouts I no longer
want to see the related or the recent
articles I just want to see related so
I'm going to enable related
and I'm going to disable the the recent
one all right so let's let's go back to
let's hear it for carrots great article
about carrots and I now have related
articles and be able to go and grow your
own herbs is showing up and the umami
got you our favorite mushrooms is there
give it a go and grow your own herbs is
there because they share the healthy tag
so I see carrots shows up feeling good
about this so far
mushrooms show up mushrooms and carrots
are both in the vegetarian tag so I'm
feeling good I panic for a second I got
to that for verses and question but so
far I haven't spent too much time on
this and now because Stephen and I'm an
ambitious developer I'm trying to level
up my skills I want to write one of
these cool automated tests I know that
the other developer on the project have
to make things go red and green I want
to make things red and green - so I'm
going to write Shehab test so I'm going
to jump over to my PHP storm here I've
got a pre normal Drupal 8 codebase
it's a composer based repository this is
just a structure you can get for using
composer based Drupal with with Pantheon
when I see that there was this articles
promoted homepage feature file that's
how this this one test was written
obviously that lead developer can write
a ton of behalf ESTs just just this one
specific to the site so I copy that file
I make articles sidebar that's where I'm
gonna put my assumed to be written D hat
test I just copy everything over from
the previous one and now I'm gonna do
what I think a lot of developers do what
I first did when I was working with the
Hat ride first do when I work with just
about anything I copy paste and then I
start modifying and I see what breaks
and what works so I just at the at the
top of this file I'm not promoting
articles to the home page and just can
call some related articles because I
don't yet really know what what I'm
supposed to do here I don't really know
what to do with this section here
and and I'm gonna find out that on a
certain level it doesn't matter later
I'll tell you that this part matters a
lot hotter I'm going to find out right
now that just from the perspective of
doing things in an automated fashion
doesn't matter at all what I put in here
so I'm just gonna say in order to put
related stuff in the sidebar as a
content editor
I need related stuff in the sidebar
again Steve here doesn't think this is a
great way to do this but Steven doesn't
know that yet and he's gonna find he can
just keep going even without without
putting a whole lot of thought into this
section I'm also just gonna say that
steven has figured out that they can use
these tags here as their call to run
just one scenario at a time that'll just
help for the purposes of the demo if I
just run one scenario at a time so I'm
going to call this related sidebar and I
really have no idea what's had this part
works under students call this scenario
related sidebar given I'm logged in as a
user with the admin role that seems like
something I can just leave there but the
rest of the rest of this right now feels
like magic I have no idea how this is
translating yet so I'm just gonna try on
the idea that this is magic
when I view an article then I see
related articles at this point that's
really all I'm thinking about how I know
that this thing is working and I'm
looking at let's hear it for carrots or
any of these articles and I see stuff
that's related and so far to me B hat
feels like magic so I'm going to work on
the premise that D hat is magic and then
I can just run related sidebars scenario
in isolation
and magic will happen come on magic all
right
so P hat is not mention that's what I
just found out he had is not magic of
that scenario that I just ran it had
three steps given I logged in as a user
with the administrator role that's in
green that still works somehow P hat was
still able to log in as a user with the
admin role but it had no idea what I
meant when I wrote when I view an
article then I see related articles P
hat doesn't know what that means yet
okay so what do I do now I feel like I
need help I probably should talk to that
the hoofer who knows more than I do
about this but I'm gonna make a mistake
and I'm not gonna do that I'm gonna do
sometimes what I myself often do is I
just I just look for the help text I'm
just gonna run the same command but with
- - ah this is you know sometimes a good
idea when you're stuck with a
command-line tool just throw a long - -
help and see what you get so Steven
reads through all of the help text here
and he gets to this part we're just
going to jump to the part that's going
to be most helpful - Steven right now
this part about definitions this looks
interesting
use definitions I'll just list
definition expressions definition I -
lists the definitions with extended info
I that what what exactly does that mean
I can run DL where were definitions
equals L and I can get to what feels
like the magic part this is this is
getting me closer to understanding how
does B hat go from those plain text
files into the world of executable PHP
where it's where it's really automating
a text so just by looking at the help
text I figured out oh I can get a list
of all of the definitions and it's not
magic it is just regular expressions
regular expressions are not sometimes
feel like like magic so I'll be hat is
doing here is pattern matching with
write regular expressions B hat somehow
knows what each of these things mean B
hat is somehow able to translate from
when I check option or when I uncheck
option or then I should be on page so as
Steven is reading through this he's
realizing coming he had is be much just
simulating browser behavior somehow
somehow it is able to simulate what
browsers do browsers go to URLs they can
move forward and backwards they can
check radio boxes okay that make sense
to me now the way the way that I
currently know that this feature is
working is I'm just going to a page like
let's hear it for Karis and that I'm
looking in the related articles region
and I'm seeing give it a go and grow
your own herbs and I'm seeing you mom
you got two favorite mushrooms that
right now that's how I know that this is
working so let's see if I can just
translate that into behead I'm a certain
level pretty much any automated test is
just a function of thinking yourself I
know that this is working and
translating that into whatever the
automated test makes available so I see
that be had allowing to just go to URLs
and check for text that's what I've
figured out just by I reading through
this this help text I'm able to just
tell be haptic to go to certain URLs and
check for text so let me let me try that
and you know what I probably don't even
need to be logged in as an admin if all
I'm doing is going to the carrots URL
and checking for text so we just just
try that comment out this stuff that
wasn't working let's just say when I go
to I just need to go to that carrots URL
then I see typo all right
oh thank you then I should see that's
the part of the live demo and I see
all right what will like it paulus let's
find out oh I think I need to say then I
should see there we go hey that was
really fast wasn't it
it just went it didn't even law again it
just went to a URL and it check for the
existence of text feeling pretty good I
got the green stuff I love the green
stuff but I'm hesitating now yes this is
how I know that this functionality is
working right now but isn't this gonna
work forever and one of the reasons I
want to do this is because I want these
tests just running over and over again
but if this ever breaks I know that it
has broken but my client is soon going
to enter just a bunch of content and if
they enter a bunch of content tagged and
healthy or vegetarian then give to go
and grow your own herbs and the amani
guide our favourite mushrooms isn't
going to be in the sidebar because this
is just sorted by date basically so if
new articles get added suddenly those
things are no longer on the page and
this test is gonna fail so alright what
do I do
I think to myself well what did what did
that other test use so this other test
somehow was them was just making content
somehow we just made a new article and
it check for that article so this test
shouldn't fail if it just keeps running
over and over again because it's making
the article that is then checked for so
okay
that's what I should do I'm gonna try
and see if I can figure out how to do
that so I'll run that that help text
again because right now I don't I have
no idea how it did this I have no idea
yet how it made a new article so I could
look at that definition list I can also
do something I often do when I'm stuck I
I just grep for text great debugging
technique where where the heck did did
this thing get defined I'm gonna grep
for for just that and just I'm just
gonna guess that it's
couldcould tests because it's related to
tests oh and hey in this file called
feature context dot php' that text is
there okay let's go there from from
chris webber yesterday I learned shift
shift the magic search everywhere so the
text again that is looking for when I
make a new article titled okay so it
looks like it looks like this is a file
that's like specific to this project
here and it looks like I could do a git
Blaine if I wanted to I could figure out
I'm the lead developer at some point
wrote a custom method that went to the
article add page filled in a title check
the promoted box and press the Save
button that's kind of cool what this is
making me realize here is that I've
heard about that balance between
automation and clarity and what this
seems to be doing is is making a dot
feature file that's that's fairly easy
to read for for someone who may not know
a ton about web development and
understand how that homepage thing works
and and the way that we're able to make
this part clear is basically by hiding
the complexity over here the complexity
of what does it mean to to make a
promoted article it's not a whole lot
it's just there are four things go to
the article creation form fill out a
title and press submit but that sounds
complicated I can't do I have to write
PHP I thought I was I thought I was just
writing B AB and B had I thought was
magic and I'd rather not write this
complex-looking PHP if I don't
I thought I could just like directly
simulate all this prosper behavior so
now I'm gonna jump to another part where
where I'm gonna cheat here I'm gonna I'm
gonna jump to a part where I'm just
gonna copy paste a perfectly long set of
these beheaded steps I'll copy this up
the top of my file
I don't think you want to watch me write
all this out manually because this is a
really long scenario I'll just use the
tag rule a bit long here so what does
this do it says logging in as an
administrator at the admin role going to
note / and / articled and I figured out
that I can just fill in form fields
using using these kinds of phrases I can
say and I fill in the title with healthy
and seasonal stuff fill the tags with
healthy of seasonal because this is just
vanilla Drupal core I don't have path of
us are going to manually do the URL
aliases so if I'm making a new article
called healthy and seasonal stuff the
way I'm going to know that the related
sidebar is working as I expect to see
articles that are both healthy and
seasonal articles that are just healthy
articles are just seasonal that's why
I've got here article healthy and
seasonal an article that's just healthy
orful is just seasonal and then an
article that has healthy seasonal and
vegetarian all of these articles should
show up in that sidebar that's how I'm
going to know that the related articles
block is working long term that's how
I'm going to know that it's working and
stays working because I'm just going to
make test content every time I need to
test for it so let's let's try running
this I call this related long not
prepping I'm running this test again
related long
go go go go go a whole lot of green here
so I've also figured out that there's
the ability to put in breakpoints so far
that has been hard for me to kind of
mentally keep track of what b-hat is
really doing here name sometimes can
execute so fast that it's hard to know
what's really happening so I found that
there's the ability to put in
breakpoints I can just write and I break
and then B hat will pause execution and
now I can manually jump over to my site
here and I see oh these are all these
are all the nodes that I made I've got
very healthy seasonal a vegetarian
article there's that healthy and
seasonal stuff thing and look all of
those articles that I just made through
an automated fashion are appearing in
the related articles side book wonderful
I'm gonna let that go my test has failed
great great great
why did it fail oh because I hey I was
tucking and pasting the wrong thing I
think Oh jumping ahead so I do expect to
see each of those those things that when
I ran it it was checking that some of
them were not there but I do want them
actually their pleasure try running a
little more time
is it get rid of articles after it's
done yes the the drupal extension that's
providing a lot of this functionality
like the ability to oh alright why my
region is not defined thank you for
reading what's actually getting output
here so where are these regions coming
from that's what I was supposed to talk
about where these regions actually
coming from through some through some
wrapping that I'll just skip over I
figured out the regions are getting
defined over here in this region map so
region maps are basically the ability to
map between short phrases like homepage
promoted article recent articles related
articles and more complex CSS selector
so what we have is doing here is knowing
that when it sees that I'm checking for
text in a region like related articles
it knows the inside of this more complex
CSS selector one more time
hey thirty-six past steps that's giving
me maybe maybe too much excitement
thirty-six past assertions Wow I must
have just done something really valuable
because I've got 36 green things so I'm
super excited I commit it I show up at
scrum the next day like a client you're
not you're gonna be so impressed you're
gonna love this
we've got the related articles they look
at the related articles and they say yep
looks good to me
and I say oh and I wrote a cool B hat
test
I hear B hat tests help you have good
conversations with your client look at
this B hat test that I wrote and they're
like this is like 50 some lines of kind
of gobbledygook kinda like I guess I
understand this going on here but okay
cool
next so I'm feeling disappointed my
client wasn't all that excited about the
fact that I I wrote this B hat test the
way I did and the next day goes by they
have entered a whole lot more content
and they say hey that related articles
thing isn't doing what I want I think oh
no I have spent too much time on related
articles how could it be wrong and they
say well the carrots article should only
be showing things that are carrots and
vegetarian and healthy and I think oh no
I could have just spent 15 seconds
asking pipeline did you want or or and
and I got it wrong so I think you know
I'm just gonna jump I'm just gonna go
switch it out so then it's it's or or so
and instead of or I come back the next
day and then my client realizes oh then
most of the related articles are empty
because there are too many combinations
here so again I've made a mistake I
should have talked through all the
possible permutations here so it wasn't
it wasn't a coincidence I was playing
Sufian Stephens before the presentation
here it's okay to make lots of mistakes
mistakes are a good way to learn here so
what I've been trying to do is show you
like a sped-up simulation of how I think
a lot of people learn
Oh basically the way I learned B hat
which is I got very interested in the
automation side of things and B had yes
it can automate things but it should be
helping us have better conversations
with our client there's that thing that
I skipped over right at the top what why
am I actually doing this
who-who needs are related sidebar who is
this this benefit and what are we
actually trying to do with a related
articles sidebar there lots of reasons
you might want to do related articles
side aren't it it might seem silly to
just write it up but it's a good idea to
get everyone on the team having a decent
understanding of why are we actually
doing related articles um maybe it is
because we're trying to reduce the
bounce rate by by showing more relevant
stuff maybe it's because we have so much
content that we don't think people are
ever going to find all the content on
our website
if we don't surface it lots of reasons
lots of different scenarios to talk
through so what's supposed to happen if
an article has only one taxonomy term
what's supposed to happen if it has ten
taxonomy terms and we're only showing
for articles does it matter that some of
these taxonomy terms aren't really
getting represented at all for only
sharing four things do we need to match
do we do actually show based on like how
many of these taxonomy terms are our
present if there are ten taxonomy terms
are we supposed to show it best matches
or things that just match any of these
terms are we so we do if there are no
taxonomy terms at all is that even
possible
do they actually want to mix curation
and automation a lot of my experience a
lot of clients will expect that on
certain article pages they can just
manually decide what is going to show up
related articles well if they don't tell
me that if we don't have a conversation
about what they actually expect that
they're never going to get that
so another mistake I've I've kind of
made here is I've skipped over the big
idea of a behavior driven development
this idea that we should be having
quality conversations with our clients
about what they actually expect so just
just to put give you another way of
thinking about it behavior driven
behavior driven development is basically
specify specification by example
figuring out what the website is
supposed to do by talking through all of
these different examples
lots of taxonomy terms no tax on many
terms we've got this concept of promoted
or supposed to be accounting for the
concept of promoted or we got the
concept of sticky at top of list we're
supposed to account for that
so this Keyhoe a major thinker the
behavior driven development community
says that having conversations is more
important than capturing conversations
which is more important than automating
conversations so be had as a way to
automate what comes out of the
conversations you have with your client
but it's much more important to have the
conversation than it is to automate it I
would have been much better off had I
just had a good conversation with my
client about what they expected from
related articles that would take it much
less time the need is spending and how
are figuring out how to automate my
incorrect assumptions with wit behead my
last job we called this idea demo driven
development just talking through how are
we going to show our client that this
thing is done you don't have to automate
it you can just at the beginning of a
sprint at the beginning of a feature
think for yourself how am I going to
show another person that this thing is
done and she just write down for
yourself how how you're going to show
that this thing is done that gets you
thinking much more much more
analytically much more deeply about what
is actually expected it's a good way of
thinking through those edge cases that
might not show up if you jump straight
to automating the this
simple case or the simple scenario so
let's let's talk through how how you can
write these scenarios in a way that will
allow them to be more readable by by
your client here so I've got another
pre-written scenario here for basically
the idea that my client has after having
all these conversations we decided it's
okay to use the or query but in order to
get really good quality content let's
use that concept of promotive if there
are promoted articles in in one of these
tags
let's get those at the top of the list
so we end up writing as a scenario
something like given I am a content
creator and I have a list of ten
articles tagged in BB q barbeque and the
sixth newest article and barbecue is is
not in the related articles for the
first article again related articles are
showing only four things at a time so
the sixth thing isn't promoted than it
shouldn't be on the list but if we go
back to that sixth thing and market is
promoted and it should start showing up
then that six the newest article will be
at the top related articles for other
vbq articles so great I think right a
scenario that I hope is more readable
more possible to my clients then then
something like this where all of the
complexity is is here at this top level
of these these plain text files that are
meant to be readable by a wide audience
the idea here is that pretty much anyone
involved in the project should be able
to read one of these files and have a
good sense of what's going on for this
file is exposing every single detail of
the browser interaction it's not
something that purpose
all right any other questions coming up
yes all right so one of the ideas that
we had here is were able to basically
hide that complexity so I saw or the
earlier that my coworker had set up that
the earlier you had test had written
custom steps here so I'm basically going
to do the same thing and that's that is
something I recommend right right out
these features in a way that is readable
before you jump to writing the PHP side
of things so again for time purposes and
I hope to avoid typos I've pre-written
these let's imagine that I haven't so
let's let's say that it's a slightly
different phrase like and I have a list
of 10 article notes so that's a step
addition that does not yet exist if I
try and run this scenario I'm going to
get that same kind of failure message
saying I don't know what you mean by 10
article notes so this is a fine place to
be if if you do like that mindset of
getting getting everything green this is
where you can get into that sort of
gamification of test-driven development
right here right now I'm in a state
where we had knew what I meant by the
first thing but this next step is
undefined it doesn't know yet what I
meant by given I have a list of of
article notes tagged in something so
that's saying you can define that so
right now I'm gonna say where I've got
one thing green I've got one thing
yellow and it's telling me if I want to
define this thing I could just copy
paste this code over to my my future
context file so let me do that
and a copy-paste it here
and then see I've pre-written the
function here that basically does the
creation of ten articles so all that's
happening here is we're looping over the
count variable using a time call to
spread these out over times that they do
sort by time and I've got a separate
helper function here for generating
individual articles where we're taking
the time adding the time to the title
going to denote slash a slash article
filling in the title field filling in
the tax field filling in URL aliases
really in the time stamp unchecking
promote because for most base week we
don't want them promoted and pressing
the Save button and don't need the
debugging of printing the current URL so
let's just let's just use that
pre-written one home delete this thing
but the breakpoint articles probably
Thanks
yes
so if I were if I were writing this
scenario out before I had built out the
drupal side of things it would fail
because the functionality didn't exist
yet for for demo purposes I I have built
out this functionality and I have done
the the promoted checkbox so let's let's
just jump over to the side see how
that's going
I should see I have a bunch of articles
tagged and vbq I see the related
articles
and that sixth most article will be at
the top of the immolated articles for
other vbq articles how am i doing that
check so that there again I'm using the
idea of a region mapping defined related
articles first here as a region
and I'll undo to check that is going to
the list of all admin content clicking
on the link for the the newest article
and then checking at the text of the
sixth most article which counting from
zero is in position five
isn't that related articles first region
so here I hope I've helped myself
balance out the tension between
something that is clear to my client
clear to my client about what this
expected behavior is and getting some
some decent automation out of it so
we're nearly at time here I do want to
put you in what I hope are some helpful
directions if the thing that that you
need most now is clarity around what
kind of conversations
should I be having with my client and I
would recommend checking out BDD
specifically again Liz Kehoe's a big
deep thinker in this space this is a
YouTube video I'll tweet at the links to
these slides here and you can follow the
links a good introduction to behavior
driven development if what you're most
interested in is the relation of b-hat
to to other kinds of automated tests and
balancing the competing priorities of
automating tests automated tests in
general this is a great blog post that
further breaks down the different
benefits you can get from automated
testing so here I've just been talking
about two benefits automation and
clarity but this blog post from from
Sarah may breaks it down into five
competing trade-offs and if what you're
looking for is just motivation on
leveling up your development workflow I
recommend checking out a book series of
blog posts from my colleague Michelle
Colucci titled no excuses this came out
I think three years ago now and it was a
big motivator for myself and I think
many others
community to level up our development
workflow and get more serious about
automated testing Thanks
[Applause]
any questions yes
resource or or tutorial and writing your
own I'm just going deeper on on writing
this part do you mean yeah the the
drupal extension documentation might be
a good place to start but some of the
back is this giving me a hand sciencing
maybe not so much I mean quite honestly
I've struggled with this you know the
often the way I've done it just by it
like looking at parent classes and
seeing what they're doing I was
wondering to to talk a little bit about
using a JavaScript
is your life it is there do you have
like do you use selenium at all in your
automated testing and what does that
look like for you your workflow one
second here
so short answer I have not had to do
much JavaScript in my my B hat tests
partly partly just because of the
project musical song haven't required it
and partly because this is just a level
of complexity that I would rather avoid
knowing that selenium setting up
selenium so for the people who are
familiar everything you saw so far
didn't involve JavaScript at all all the
form fields I was filling out the
buttons I was clicking JavaScript wasn't
getting processed at all and one of the
reasons for it growing the JavaScript is
everything just runs much faster when
you ignore the JavaScript of course
there's plenty of functionality that you
do need JavaScript executing in order to
test we need to add more complexity to
your he had set up in order to
accommodate that the traditional way of
doing stuff has been with a tool called
selenium that they able to connect you
to a real browser the thing I've been
experimenting with though is skipping
over this learning part and talking to
chrome more directly with this thing
relatively new I just came across this
repo a few months ago the chrome link
driver and as I was planning at this
session a month ago I was thinking
wouldn't it be amazing if I could be
running these b-hat tests and just you
could just see chrome getting controlled
by a robot and filling out the form
fields so I have got networking kinda
the reason I didn't use it in the
presentation is because I haven't found
it to be reliable at all much of what
what I was doing here was you know
filling out filling out form fields and
when I've been using headed chrome
basically using a version of Chrome
ramble where I'm able to see what's
happening and it just doesn't sometimes
it just fails and I'm ready
that passes so I didn't want to do that
for for the demo but the the normal way
of using it is in a headless fashion
basically where yes prohm is being used
you just can't see it
you just have to trust that it's working
so if I did have to execute JavaScript
in my V hat tests you know tomorrow I
would try and use it with headless
chrome yeah four four nine P hat
purposes I've been able to get headless
prom running inside of circle see I like
a lot of the testing examples we short
Pantheon show visual regression testing
or basically or screenshotting the live
environment on the side of your screen
shopping like another environment where
maybe like WordPress core Drupal core
has been updated and the idea is that if
none of the pixels move between the live
version of the site and the version of
the safest and cut the security update
to be good indication that the security
updates safe reply all that to say the
tool that does that a kind of screenshot
comparison back to top j/s on that we've
been using executes much faster with
headless chrome than it than it does
with phantom j/s which is
a more stimulated browser and in
JavaScript that just runs slower than
chrome does
all right well thank you everyone