Put open source to work
July 16–17, 2018: Training & Tutorials
July 18–19, 2018: Conference
Portland, OR

A gentle introduction to TDD in Go

Luciano Ramalho (ThoughtWorks)
9:00am12:30pm Tuesday, July 17, 2018
Emerging languages
Location: C123/124
Level: Beginner
Average rating: ***..
(3.00, 3 ratings)

Who is this presentation for?

  • Go programmers

Prerequisite knowledge

Materials or downloads needed in advance

What you'll learn

  • Learn how to implement test-driven design and how to test code that interacts with OS services like the command line, environment variables, the filesystem, and the network

Description

Most Go tutorials and introductory texts leave testing to the end; many just skip the topic. However, knowing how to test Go code is a key job requirement. It can also help you master Go faster by letting you easily test your hypotheses as you practice the language.

Luciano Ramalho offers an introduction to test-driven development, covering essential testing techniques that make the test-first approach practical and even enjoyable. You’ll use TDD to develop a utility from scratch: runes, a command-line program that lets you search Unicode characters by name. (Luciano uses it daily to find special symbols and emojis.)

Outline:

  • Getting started with TDD
  • A first function, thoroughly tested
  • Testing code that produces text output
  • Testing the main function
  • Faking command-line arguments in tests
  • MVP1: A working runes executable
  • Table-driven subtests for enhancing precision and recall
  • Faking environment variables in tests
  • Faking remote HTTP access
  • Testing code that creates files
  • Making slow tests optional
  • Testing the finished product
Photo of Luciano Ramalho

Luciano Ramalho

ThoughtWorks

Luciano Ramalho is a principal consultant at ThoughtWorks and the author of Fluent Python. Luciano wrote the Introduction to Go with TDD tutorial (in Portuguese) and has presented it multiple times. He is a cofounder of Garoa Hacker Clube, the first hackerspace in Brazil.