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 it pass, and finally clean up the code. It helps catch bugs early and improves design.
Click to reveal answer
beginner
In Swift, which framework is commonly used for writing unit tests?
XCTest is the standard framework in Swift for writing and running unit tests.
Click to reveal answer
beginner
What are the three main steps in the TDD cycle?
1. Write a failing test.<br>2. Write code to pass the test.<br>3. Refactor the code to improve it without breaking the test.
Click to reveal answer
intermediate
Why should tests be written before the actual code in TDD?
Writing tests first helps you think about what the code should do, ensures requirements are clear, and prevents writing unnecessary code.
Click to reveal answer
beginner
How do you run tests in Xcode for a Swift project?
You can run tests by pressing Command+U or by clicking the diamond icon next to the test method or class in Xcode.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 Swift framework is used to write unit tests?
✗ Incorrect
XCTest is the built-in framework for unit testing in Swift.
What does the 'Refactor' step in TDD mean?
✗ Incorrect
Refactoring means cleaning up code to make it better without changing what it does.
Why is TDD helpful in app development?
✗ Incorrect
TDD helps find bugs early and encourages writing clean, well-designed code.
How do you run all tests in Xcode?
✗ Incorrect
Command+U runs all tests in the current Xcode project.
Explain the Test-Driven Development cycle and why it is useful in Swift app development.
Think about the order of writing tests and code, and how it helps improve quality.
You got /4 concepts.
Describe how to write and run a simple unit test in Swift using XCTest.
Remember the basic structure of a test and how to check results.
You got /4 concepts.