Test Your Code the Sane Way (QA and Tech Debt Pt 3)
This series is about building quality tech products specifically geared toward tech startups.
Here we talk about reducing tech debt via a sensible testing process from unit tests to integration tests, e2e tests, and even visual regression testing.
Transcripts (the following transcripts are auto-generated and may have typos or inaccuracies):
so let’s get into the last thing
you can add to this stack to
dramatically improve the quality of your
Tech and the speed at which your tech
company is able to deliver features to
Market
and that is
um code that tests code arcanium
welcome to a production by Dr Miles
Aaron
CEO and co-founder at arcanium ventures
don’t forget to subscribe subscribe
subscribe
so this is testing now and when we look
at testing there are a lot of things you
can do there’s a lot of hot takes on
this I certainly have my own but I’ll
just say at a high level
that you’ve got unit tests which might
be testing a function or or a set of you
know a function that runs some business
logic and a unit test is going to say
you know this function is supposed to
add two numbers and it’s going to throw
some test examples in there
um maybe it’ll even generate you know 50
or 100 of them randomly if it’s a better
test and say do these two numbers add up
to what they’re supposed to based on
this function and the expected output
um and there’s there’s a lot of depth
and and um
there’s a lot of nuance that can go into
writing unit tests but unit tests are
kind of like level one you’re just
covering does this function do what it’s
supposed to do
level two would be integration testing
integration testing is saying I have a
service it’s talking to another service
um if I ping this service am I getting
back what I’m expecting and uh again
there’s a lot of complexity we can
uncover there but in a basic sense
you’re you’re going beyond the unit of
software and you’re talking about
communication across modules or across
Services
um and when you go to across Services
some people might even consider that
end-to-end testing end-to-end testing is
our third level end-to-end testing is
saying look I don’t really care what
happens in between but I want to know
that when I press this button I’m
getting this result back now a lot of
things can happen in between but I’m
basically testing n10 does it go end to
end and do what I want it to do
um so on the testing front you know it
is a big lift if you’re going to walk
into a tech company maybe you’re a new
CTO or director of technology or the CTO
now and you’re thinking oh I got to get
my tech under control things are slow
and if you just say hey we’re going to
go for a 100 test coverage day one one
you’re gonna demoralize all your
engineers you’re gonna piss off your CEO
because you’re going to be way too slow
to get things out
um
and so what my recommendation is is to
do two things you can look at two things
to know where should I have a test and
then you can prioritize those
um so the two areas are
where’s my code getting touched the most
so this is easy you can go into your
GitHub or your bitbucket and just look
at where what files are getting
committed the most the most likely
things to break are the things that
people are touching so it’s easy don’t
don’t write tests for something that’s
been working for 10 years it works right
but if it’s getting changed every week
you probably want to test in place
um and the second thing you can do is
say what are the most critical things
for my business what is uh what are the
components on the page what are the
pages that are required to make a sale
or to
um it to retain a customer or to get a
customer to refer someone these are the
things that are going to drive your
business
and so Focus first on those highly
critical elements and make sure that
they’re tested whether it’s unit tests
on the business logic integration tests
for API calls or end-to-end tests
um and there’s a there’s another side of
testing that I can recommend for these
early companies to look at although it
might depending where you are in the
journey it might be premature but that
is um the side of visual regression
testing and there’s a a really cool new
suite of tools that are coming out that
allow you to do this in a no code way so
you know if you’re on a budget or your
early stage I’d recommend looking at no
code tools for
um for regression testing or visual
regression testing but the idea here
is that basically you have something in
your deployment pipeline that takes an
image of every page when it comes out
you can tell it what where to look and
it says
um
upon every new piece of code that comes
out let’s check let’s take a new
snapshot and let’s compare those two
snapshots and see what does and doesn’t
line up and let’s flag that now you can
have this prevent a pull request from
going through so you have complete
control over the quality there or you
could just have it flag it and you can
decide do I wanna is that does it matter
to me that this changed I mean look
you’re going to be changing your UI so
of course changes are going to happen
you have to let some changes through but
it just brings to the surface like oh
you know these two things were coupled
and I didn’t realize and so I changed
the button over here and QA passed it
and it went into production and my users
are seeing it but I forgot that button
is getting used on this page and the
padding change now it broke a layout now
it looks terrible this happens all the
time visual regression testing is a
low-cost easy way
of at least getting awareness of where
those things might be breaking and the
no code tools that are coming out go a
step further many of them and
get into this kind of automated testing
sphere
um you know previously this was done
with like Puppeteer and selenium but um
there are tools that that make it much
cheaper to get into where you’re
basically going to say hey there are
these user actions I’ve got an ID on a
button user is going to scroll down x
amount they’re going to click that
button then this thing is supposed to
happen and you kind of get a sequence of
events that you can program to tell your
testing software hey when I release this
I want to make sure these 50 critical
user actions run perfectly no matter
what code we’re putting through no
matter what new feature we’re adding so
that’s another way that you can clamp
down on the quality