PyCon Taiwan
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- title: 成功地測試失敗 (Fail tests successfully) - Keith Yang tags: PyConTW2021, 2021-organize, 2021-共筆 --- # 成功地測試失敗 (Fail tests successfully) - Keith Yang {%hackmd f0JLCtZCTiWo4ZBRNKd8cg %} <iframe src="https://app.sli.do/event/9rgrmtht" height=450 width=100%></iframe> <iframe src="https://wall.sli.do/event/9rgrmtht?section=b9378313-c568-4125-a089-deb25608cd6d" height=450 width=100%></iframe> > 從這開始共筆 ## 逛逛測試場景 - 場景一:團隊 coverage 不正常發揮提升 - 場景二:升級套件導致測試問題 - 場景三:Jenkins 有在好好工作~ ## 講者背景 - iCHEF lead backend engineer - Tiapei.py co-organizer ## 測試帶來的好處 - Hypothesis - 測試對大家都好 - 團隊的期待 - 關鍵價值的速度和品質 - 品質:程式碼測試覆蓋率 (code coverage) - pull-request 的 review 人數 - 開發時的整合問題、上線前 QE 驗出的問題數 - hotfix 上線後的重大問題數 - 測試數量與角度 - … - 測試常見場景 - CI 提報 coverage 掉太多 - QA 問有沒有 unit test - 第三方 API 只能在正式測試卻不能在測試環境測試 - 經驗 - 說服力有限,有可能有用但也可能沒用 ## 工具簡介 - unittest.mock - 用來仿製程式的一些行為 - pytest - 簡單地寫測試,出錯時得到更詳細資訊 - coverage - 計算並輸出程式覆蓋率 - vcrpy - 錄下打出去的 requests - Jenkins 2 pipeline - 同時跑多個測試 - 功能還在持續增加 ## 沒有測試的壞處,如何測好、測到 - 優先等級問題 - 注意事項 - 寫測試的時候應避免重複寫原來的程式邏輯 - 不要因為著急而跳過測試 - 沒有測試的話 - 會花更多時間在上線前的來回 - 可能有些問題還沒修好就上線,引發更多新問題 - 經驗 - 使用pytest測試第三方api,在非prod的branch中執行,避免突發性的api錯誤 - 用三元表達式,可能覆蓋率不準確 - 什麼都要測試嗎? - 關鍵的測試有測到更重要! - 測試是為了速度與品質 - 不好的"快"不是"真的快" - 簡明的程式與測試很棒 - 追求"測到關鍵邏輯" ## 總結 > 預防勝於治療 - 測試是為了==速度==和==品質== - ==簡明==的程式與測試,持續追求==測到關鍵邏輯== ## iCHEF 招募中~快來 ## Q & A - 來不及問問題啦~大家直接到 R0 講者交流區去問 Keith 吧 :smiling_face_with_smiling_eyes_and_hand_covering_mouth: ### Slido 上的問題 Q: 想問一下 pytest.mark.parametrize 與 Django 碰到的問題是什麼 A: pytest 的 fixture 與 parametrize 不支援 unittest.TestCase https://docs.pytest.org/en/latest/how-to/unittest.html#pytest-features-in-unittest-testcase-subclasses Q: 寫測試的策略會影響到 code review 嗎?兩者的交互作用 (如果有的話) 是如何? A: 舉例來說,code review 要求有邏輯就要寫測試 -> pull request 就會有測試。pull request 裡的 code 沒有測試,review 的人需要自己用腦編譯確認程式沒有 syntax error 等低級錯誤,或著有時難猜是想完成什麼樣的 spec。 ###### tags: `PyConTW2021`

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully