From 2d4701b4c823bd8e8059adb220eede2d0bdf35c6 Mon Sep 17 00:00:00 2001
From: Hau Nguyen
Date: Wed, 24 Jan 2024 12:51:38 +0700
Subject: [PATCH] feat: draft test
---
docs/2024-01-20-backend-thinking.html | 54 +++++++++++++++++++--------
posts/2024-01-20-backend-thinking.md | 30 +++++++++------
2 files changed, 58 insertions(+), 26 deletions(-)
diff --git a/docs/2024-01-20-backend-thinking.html b/docs/2024-01-20-backend-thinking.html
index 166e780..f260b5e 100644
--- a/docs/2024-01-20-backend-thinking.html
+++ b/docs/2024-01-20-backend-thinking.html
@@ -109,8 +109,8 @@
processing, ...
- Example: UM (Team User Management Core) has 10+ Java services and
- 30+ Go services.
+ Example: Team UM (User Management) has 10+ Java services and 30+
+ Go services.
The question is for each new business requirements, what should we do:
@@ -366,9 +366,8 @@
code is actually what we think/expect.
- Best case scenerio is test with real dependencies (real servives, real
- Redis, real MySQL, real Kafka, ...). But it's not easy way to setup
- yourself.
+ Best case is test with real dependencies (real servives, real Redis, real
+ MySQL, real Kafka, ...). But it's not easy way to setup yourself.
The easier way is to use mocks. Mock all dependencies to test all possible
@@ -391,17 +390,34 @@
- Integration tests in 2 ways:
+ Integration tests is to test your system as a whole package, can be in 2
+ ways:
-
Locally, which require to run in your computer with fully set up
dependencies, is hard to set up.
- - Remotely, use DEV env to test APIs.
+ -
+ Remotely, use DEV/... env to test full business flow with all
+ possible scenario.
+
TODO: Show example
+ How to make code easier to test. Same idea loosely coupled as above.
+ Some tips:
+
+ - Rely on abstraction/interface to mock
+ -
+ Limit relying on variable outside input (global variable, environment
+ variable, ...)
+
+ -
+ If deleting/adding code but tests are still passed, then maybe your
+ tests are wrong/not enough (tests is missing some code path).
+
+