Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Unit Testing in Go
Search
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
79
Cara Cerdas Menjadi Software Engineer
haritsfahreza
0
42
Other Decks in Programming
See All in Programming
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
220
Implementation Patterns
denyspoltorak
0
120
マスタデータ問題、マイクロサービスでどう解くか
kts
0
130
開発に寄りそう自動テストの実現
goyoki
2
1.4k
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
180
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
770
ELYZA_Findy AI Engineering Summit登壇資料_AIコーディング時代に「ちゃんと」やること_toB LLMプロダクト開発舞台裏_20251216
elyza
2
630
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
280
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
150
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
4k
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
430
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
400
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
Making Projects Easy
brettharned
120
6.5k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
120
Measuring & Analyzing Core Web Vitals
bluesmoon
9
710
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
190
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
The Invisible Side of Design
smashingmag
302
51k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
30
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
69
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]