Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Unit Testing in Go
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Harits Fahreza Christyonotoputra
August 29, 2018
Programming
0
68
Unit Testing in Go
Unit Testing 101 and how to implement unit testing in Go
Harits Fahreza Christyonotoputra
August 29, 2018
Tweet
Share
More Decks by Harits Fahreza Christyonotoputra
See All by Harits Fahreza Christyonotoputra
Multi-Country Architecture
haritsfahreza
0
180
Build Your Cool REST API using Node.js
haritsfahreza
0
68
Backend Engineering in Ruangguru
haritsfahreza
0
80
Cara Cerdas Menjadi Software Engineer
haritsfahreza
0
42
Other Decks in Programming
See All in Programming
Raku Raku Notion 20260128
hareyakayuruyaka
0
280
Fragmented Architectures
denyspoltorak
0
160
CSC307 Lecture 07
javiergs
PRO
0
550
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
110
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
CSC307 Lecture 02
javiergs
PRO
1
780
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.5k
ぼくの開発環境2026
yuzneri
0
230
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
450
30 Presentation Tips
portentint
PRO
1
220
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
53
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
Evolving SEO for Evolving Search Engines
ryanjones
0
120
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Automating Front-end Workflow
addyosmani
1371
200k
My Coaching Mixtape
mlcsv
0
48
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
WENDY [Excerpt]
tessaabrams
9
36k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
Transcript
Unit Testing in Go Harits Fahreza Christyonotoputra
[email protected]
Unit Testing? “One of the methods that used to make
sure your code is not broke” “...unit tests are not an effective way to find bugs or detect regressions. They examine each unit of your code separately”
import “testing”
None
None
> go test
> go test -cover
Tips for writing a good Unit Test
Do • Make Them Short • Make Them Fast •
100% Pass • Give a good name • Design your test • Try it by yourself
Don’t • Repeat Yourself • < 100% Pass • Hard
to Read
Cool Libs
github.com/stretchr/testify
github.com/vektra/mockery
github.com/Selvatico/go-mocket
github.com/Selvatico/go-mocket
github.com/jarcoal/httpmock
Want more? github.com/avelino/awesome-go#testing
Conclusion • Unit Test just to make sure your code
is not broke • It is not an effective way to find bugs or detect regressions • It examine each unit of your code separately • Go has default `testing` package • There are tools and libs that can help us to make a good unit test
References • https://blog.alexellis.io/golang-writing-unit-tests/ • http://blog.stevensanderson.com/2009/08/24/writing-great -unit-tests-best-and-worst-practises/ • https://dzone.com/articles/10-tips-to-writing-good-unit-tests
Next Stop? • TDD • Improve Code Quality • Integration
Test
Maturnuwun! Harits Fahreza Christyonotoputra
[email protected]