Welcome to your first lesson dedicated to practicing Test Driven Development (TDD) using Scala 3 and ScalaTest. Test Driven Development is an effective methodology that emphasizes writing tests before developing code. This approach assists in designing your application with a focus on testing as a crucial element, ensuring each component performs as expected. In this lesson, you'll grasp the fundamentals of TDD along with the Red-Green-Refactor cycle, understanding their significance in creating reliable and maintainable code.
This course involves hands-on practice, where you'll encounter requirements incrementally through tests. Your task is to implement code that satisfies each test, mirroring a real-world TDD scenario. Consider this course guide as your pair programmer, offering test-driven prompts to enhance your proficiency as you progress.
As a reminder, the Red-Green-Refactor cycle is central to TDD, guiding your development process:
- Red: Begin by writing a failing test to establish the next goal.
- Green: Develop just enough code to pass the test, emphasizing functionality.
- Refactor: Improve the code for clarity and efficiency without altering its behavior.
In this lesson, we'll be using AnyFunSpec from ScalaTest to define and execute our tests. Below, you'll find the detailed requirements and corresponding test cases for the calculateDiscount
function. Each requirement directs you through the TDD process, focusing on specific behaviors the function must demonstrate.
