Skip to content

Commit 3597ad6

Browse files
authored
Merge pull request #13 from ExtensionEngine/automated-testing/update-e2e-part
Rephrase E2E, Performance, and Visual test sections
2 parents 2381429 + 2be0f32 commit 3597ad6

File tree

1 file changed

+83
-40
lines changed

1 file changed

+83
-40
lines changed

recipes/automated-testing.md

Lines changed: 83 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -174,91 +174,134 @@ performance tests (K6).
174174

175175
#### Antipatterns
176176

177-
178177
### E2E Tests
179178

180-
These tests are executed within a browser environment (Playwright, Selenium, etc.).
181-
The purpose of these tests is to make sure that interacting with the application UI
182-
produces the expected result.
179+
E2E tests are executed in a browser environment using tools like Playwright,
180+
Selenium, or similar frameworks. The purpose of these tests is to make sure that
181+
interacting with the application UI produces the expected result, verifying the
182+
application’s functionality from a user’s perspective.
183183

184184
Usually, these tests will cover a large portion of the codebase with least
185-
amount of code.
186-
Because of that, they can be the first tests to be added to existing project that
187-
has no tests or has low test coverage.
185+
amount of code. Because of that, they can be the first tests to be added to
186+
existing project that has no tests or has low test coverage.
188187

189-
These tests should not cover all of the use cases because they are the slowest to
190-
run. If we need to test edge cases, we should try to implement those at a lower
191-
level (integration or unit tests).
188+
These tests should not cover all of the use cases because they are the slowest
189+
to run. If we need to test edge cases, we should try to implement those at a
190+
lower level (integration or unit tests).
192191

193192
#### When to use
194-
- Test user interaction with the application UI.
193+
- To validate user interactions and critical workflows in the application UI.
194+
- For testing specific user flows.
195+
- For making sure that critical application features are working as expected.
196+
- For better coverage of the most common user pathways.
195197

196198
#### When **not** to use
197199
- For data validation.
198200

199201
#### Best practices
202+
- Tests should be atomic and simple, all complicated tests should be thrown out.
203+
- Focus on the most important user workflows rather than attempting exhaustive
204+
coverage.
205+
- Each test should be able to run independently, with the environment reset to a
206+
known state before every test.
200207
- Performance is key in these tests. We want to run tests as often as possible
201208
and good performance will allow that.
202209
- Flaky tests should be immediately disabled and refactored. Flaky tests will
203-
cause the team to ignore or bypass the tests and these should be dealt with immediately.
210+
cause the team to ignore or bypass the tests and these should be dealt with
211+
immediately.
212+
- Ensure consistent data states to avoid test failures due to variability in
213+
backend systems or environments.
214+
- Run tests in parallel and isolate them from external dependencies to improve
215+
speed and reliability.
216+
- Automate E2E tests in your CI/CD pipeline to catch regressions early in the
217+
deployment process.
204218

205219
#### Antipatterns
220+
- Avoid trying to cover all use cases or edge cases in E2E tests; these are
221+
better suited for unit or integration tests.
206222

207223
### Performance Tests
208224

209-
These types of tests will reproduce a typical user scenario and then simulate a
210-
group of concurrent users and then measure the server's response time and overall
211-
performance.
212-
213-
They are typically used to stress test the infrastructure and measure the throughput
214-
of the application. They can expose bottlenecks and identify endpoints that need
225+
Performance tests replicate typical user scenarios and then scale up to simulate
226+
concurrent users. They measure key performance metrics such as response time,
227+
throughput, error rate, and resource utilization. These tests help uncover
228+
bottlenecks and identify specific endpoints or processes that require
215229
optimization.
216230

217-
Performance tests are supposed to be run on actual production environment since
218-
they test the performance of code **and** infrastructure. Keep in mind actual
219-
users when running performance tests. Best approach is to spin up a production
220-
clone and run tests against that environment.
231+
Performance tests are supposed to be run on a production-like environment since
232+
they test the performance of code **and** infrastructure. It's essential to
233+
consider real user behavior when designing and running these tests. The best
234+
practice is to create a clone of the production environment for testing
235+
purposes, avoiding potential disruption to actual users.
221236

222237
#### When to use
223-
- To stress test infrastructure.
224-
- To measure how increased traffic affects load speeds and overall app performance.
238+
- To stress test application's infrastructure.
239+
- To evaluate the app’s behavior and performance under increasing traffic.
240+
- To identify and address bottlenecks or resource limitations in the
241+
application.
242+
- To ensure the application can handle anticipated peak traffic or usage
243+
patterns.
225244

226245
#### When **not** to use
227-
- To test if the application works according to specs.
246+
- To verify functional requirements or application features.
228247
- To test a specific user scenario.
229248

230249
#### Best practices
231-
- These tests should mimic actual human user in terms of click frequency and page
232-
navigation.
233-
- There should be multiple tests that test different paths in the system, not a
234-
single performance test.
250+
- Establish clear goals. Are you testing scalability, stability, or
251+
responsiveness? Without these objectives, tests risk being unfocused, resulting
252+
in meaningless data.
253+
- Include diverse scenarios that represent different user journeys across the
254+
system, not just a single performance test/scenario.
255+
- Use a clone of the production environment to ensure the infrastructure matches
256+
real-world conditions, including hardware, network, and database configurations.
257+
- Schedule performance tests periodically or before major releases to catch
258+
regressions early.
259+
- Record and analyze test outcomes to understand trends over time, identify weak
260+
points, and track improvements.
261+
- Performance testing should not be a one-time task; it should be an ongoing
262+
process integrated into the development lifecycle.
235263

236264
#### Antipatterns
237265
- Running these tests locally or on an environment that doesn't match production
238-
in terms of infrastructure performance. (tests should be developed on a local
239-
instance, but the actual measurements should be performed live)
240-
266+
in terms of infrastructure performance. Tests should be developed on a local
267+
instance, but the actual measurements should be performed live.
268+
- Ignoring data variability, ensure the test data mirrors real-world conditions,
269+
including varying user inputs and dataset sizes.
270+
- Ignoring randomness in user behavior, ensure the tests mimic actual user
271+
behavior, including realistic click frequency, page navigation patterns, and
272+
input actions.
241273

242274
### Visual Tests
243275

244-
The type of test where test runner navigates to browser page, takes screenshot
245-
and then compares the future screenshots with the reference screenshot.
276+
The type of test where test runner navigates to browser page, takes snapshot and
277+
then compares the snapshot with the reference snapshot.
246278

247-
These types of tests will cover a lot of ground with the least effort and can
248-
easily indicate a change in the app. The downside is that they're not very precise
249-
and the engineer needs to spend some time to determine the cause of the error.
279+
Visual tests allow you to quickly cover large portions of the application,
280+
ensuring that changes in the UI are detected without writing complex test cases.
281+
The downside is that they're requiring engineers to invest time in identifying
282+
the root cause of errors.
250283

251284
#### When to use
252-
- When we want to cover broad range of features.
253-
- When we want to increase test coverage with least effort.
254285
- When we want to make sure there are no changes in the UI.
255286

256287
#### When **not** to use
257288
- To test a specific feature or business logic.
258289
- To test a specific user scenario.
259290

260291
#### Best practices
261-
- Have deterministic seeds so the UI always renders the same output.
292+
- Ensure the UI consistently renders the same output by eliminating randomness
293+
(e.g., by always using same seeds data or controlling API responses to always
294+
return same values).
262295
- Add as many pages as possible but keep the tests simple.
296+
- Consider running visual tests at the component level to isolate and detect
297+
issues earlier.
298+
- Define acceptable thresholds for minor visual differences (e.g., pixel
299+
tolerance) to reduce noise while detecting significant regressions.
263300

264301
#### Antipatterns
302+
- Avoid creating overly complicated visual tests that try to simulate user
303+
behavior. These are better suited for E2E testing.
304+
- Visual tests should complement, not replace other types of tests like E2E
305+
tests. Over-relying on them can leave functional gaps in coverage.
306+
- Blindly updating snapshots without investigating failures undermines the
307+
purpose of visual testing and risks missing real issues.

0 commit comments

Comments
 (0)