Recall & Review
beginner
What is Test-Driven Development (TDD)?
TDD is a way to write software where you first write a test that fails, then write code to make the test pass, and finally clean up the code. It helps catch mistakes early and guides design.
Click to reveal answer
beginner
In Go, which package is commonly used for writing tests?
The
testing package is used in Go to write tests. It provides tools to create test functions and check results.Click to reveal answer
beginner
What is the typical order of steps in TDD?
1. Write a failing test.<br>2. Write code to pass the test.<br>3. Refactor the code.<br>4. Repeat.
Click to reveal answer
beginner
How do you name a test function in Go?
Test functions start with
Test followed by a name, for example, TestAdd. They take a pointer to testing.T as a parameter.Click to reveal answer
beginner
Why is writing tests first helpful?
Writing tests first helps you think about what your code should do before writing it. It makes your code clearer and reduces bugs.
Click to reveal answer
What is the first step in Test-Driven Development?
✗ Incorrect
In TDD, you start by writing a test that fails to define what the code should do.
Which Go package do you import to write tests?
✗ Incorrect
The
testing package provides tools for writing tests in Go.How should a test function be named in Go?
✗ Incorrect
Test functions in Go start with
Test followed by a descriptive name, with uppercase T.What do you do after making a failing test pass in TDD?
✗ Incorrect
After passing the test, you clean up or improve the code without changing its behavior.
Why is TDD useful?
✗ Incorrect
TDD helps find mistakes early by writing tests first.
Explain the three main steps of Test-Driven Development.
Think about the cycle of writing tests and code.
You got /3 concepts.
Describe how to write a simple test function in Go using the testing package.
Remember the naming and parameter rules for Go tests.
You got /3 concepts.