Transcript

In this video, learn about the kinds of end-to-end tests that are most valuable to write with Cypress. After watching this video, you will know which scenarios to test in your application and how to structure end-to-end tests to improve test suite performance.

You will learn:

  • what real-world, happy path tests are
  • what unhappy path tests are
  • why end-to-end tests should cover realistic, happy path scenarios and align with business requirements
  • how testing every scenario in your application can hurt test suite performance and maintainability

Image Attributions:


00:00
(happy music)
00:03
Welcome back to Test Double's intro course
00:06
on End-to-end Testing with Cypress.
00:09
In the last video, you installed Cypress,
00:12
initialized a test suite, and wrote your first test.
00:16
Before diving deeper into testing with Cypress,
00:19
you will learn more about the kinds of tests
00:21
that are valuable to write with Cypress.
00:23
In this video, you will:
00:25
learn what real-world, happy path tests are,
00:29
learn what unhappy path tests are,
00:31
learn the importance of writing business-valuable tests,
00:35
and learn how the number of end-to-end tests
00:38
impacts test suite speed and maintenance.
00:41
Let's get started.
00:43
So, what is a real-world happy path test?
00:46
Let's explore each of those concepts.
00:49
In the context of end-to-end testing,
00:51
real-world test is a phrase I use to describe a test
00:55
that mimics the flow a real user
00:57
would take with an application.
00:59
For example, on a web app for booking flights,
01:03
a real-world test could be searching
01:05
for round trip tickets given travel dates,
01:08
selecting a flight from the available options,
01:11
choosing airplane seats,
01:13
providing traveler information, and confirming the booking.
01:17
Those are all steps a real user would take,
01:20
so you would include all of those steps in a single test.
01:24
That may sound counterintuitive if you're more familiar
01:27
with unit tests where you typically handle
01:29
multiple test cases, each with a single assertion.
01:33
End-to-end tests are sometimes known as feature tests
01:36
because they usually run through a feature
01:38
that is driven by business requirements.
01:41
In other words, end-to-end tests should ideally align
01:44
with business requirements to verify a software team
01:47
is building what is being asked for.
01:50
Another reason for putting so many steps
01:52
in one test is speed.
01:54
Remember, from the first video, that, typically,
01:57
end-to-end tests are slow because they involve
01:59
the full software stack and drive a real browser.
02:03
If you break up an end-to-end test
02:05
into multiple smaller tests, you multiply the high cost
02:09
of data setup, running through the whole stack,
02:12
and driving the browser for each test.
02:15
Returning back to our beginning definition,
02:17
these tests are usually also happy path tests.
02:21
A happy path test is a real-world test
02:24
that mimics the ideal or best case user scenario.
02:28
Our previous flight booking example is a happy path test.
02:32
The user in the test successfully books a flight
02:35
with no issues during any of the steps.
02:38
An example of an unhappy path
02:40
would test that one or more of the steps fail
02:43
and would ensure that an appropriate error message
02:46
or recovery path is presented to the user.
02:49
Although it's valuable to know your application
02:51
handles exceptions appropriately,
02:54
if you try to test all failure scenarios
02:57
you will drastically slow down
02:58
what is already a slow test suite.
03:01
Also, recall that end-to-end tests are harder to debug
03:04
because there are more points in the stack
03:06
that could cause your test to fail unexpectedly.
03:09
The more end-to-end tests you have,
03:12
the harder it will be to maintain them
03:13
if you encounter unexpected failures
03:16
because you're spending time debugging tests.
03:19
We will revisit this in a later video,
03:21
but there are some ways to reduce the cost of speed
03:24
and debugging in order to test expected failure scenarios
03:28
if your team finds those tests valuable.
03:30
Given all those reasons, Test Double generally recommends
03:34
limiting end-to-end tests to the most business-valuable,
03:37
realistic, happy path scenarios in your application.
03:41
Let's recap what you learned in this video.
03:44
You learned what real-world happy path tests are,
03:48
what unhappy path tests are,
03:50
the importance of writing business-valuable tests,
03:54
and how the number of end-to-end tests
03:56
impacts test suite speed and maintenance.
03:59
In the next video, you will write a real-world
04:01
happy path test for the yams application
04:04
as well as learn new commands
04:06
and selectors for interacting with forms.
04:08
(happy music)

« Start at the beginning

‹ End-to-end Testing with Cypress Series: 02 Getting Started

End-to-end Testing with Cypress Series: 04 Happy Path Tests ›

Jeremy Fairbank

Hash An icon of a hash sign Code Name
Agent 0029
Location An icon of a map marker Location
Maui, HI