Test-driven development, or TDD, is the practice of writing your tests firsts, then using those tests to guide you as you write your actual production code. This may sound crazy, but it turns out that it makes writing code much easier. It provides a clear workflow and next steps while you're building and has the added benefit of producing a test suite you can have confidence in. With these courses and videos we'll teach you everything you need to know to get started with TDD.
With a solid test suite, you'll have more confidence every time you push a change up to production. You'll also be able to refactor with confidence, changing the structure of your application and remaining certain that all the important functionality still works. Even better, since TDD forces you to interact with your code as you test it, it provides great feedback as to when you might want to clean up some of the rough edges.
The aim of test driven development is to produce code that is as simple as possible in order to meet all required criteria, and many of our training graduates (and others who have learned these methods) find that it’s also a great way to produce very robust code. By its very nature the finished product has been tested rigorously by the time it’s ready to roll out.
We think that test driven development is a great skill for aspiring coders to have, and our tutorials are the ideal place to start. We begin by introducing the concepts and by the time you’ve finished the training, you should have a full toolbox ready to deploy TDD in the real world.
Learn to use stubs, mocks, spies, and fakes with RSpec.
Learn to use stubs, mocks, spies, and fakes with RSpec.
Learn to set constraints on stubbed methods using RSpec.
Learn to unit test methods with side effects and mutation using mocks.
Learn how to keep your unit tests tidy with an alternative to mocks: spies.
Learn how to test complex or flexible interactions by using fakes.
Now that you've learned how to use stubs, mocks, spies, and fakes, it's time to pull it all together.
So you want to get started with Ruby testing. All the cool kids are doing it. Seriously though, testing is fundamental. In this course of tutorials you’ll learn methods for improving code quality and minimizing time required to add new features to software by ensuring that each facet of the program works as expected.
So you want to get started with Ruby testing. All the cool kids are doing it. Seriously though, testing is fundamental. In this course of tutorials you’ll learn methods for improving code quality and minimizing time required to add new features to software by ensuring that each facet of the program works as expected.
In this exercise, you'll write an RSpec model test to verify a simple validation.
In this example, we'll be using Capybara to write an integration test.
In this example, you'll write a unit test to make sure the create action for PeopleController works as expected based on the return value of save.
Time to put it all together! In this exercise, you'll add enhance a small Rails applications by adding the ability edit existing people. You'll implement the necessary actions and views in the Rails application, writing tests as you go.
Learn Test-Driven Rails Development using RSpec and Capybara in this series of tutorials. As part of the course, you can follow along with Josh as he lets his test drive through each of the steps needed to build out an application.
Learn Test-Driven Rails Development using RSpec and Capybara in this series of tutorials. As part of the course, you can follow along with Josh as he lets his test drive through each of the steps needed to build out an application.
Time to write our first test! In this video, Josh discusses how to lay the foundation of a test suite within a Rails application, outlines the structure of an acceptance test, and writes an initial test ensuring we can interact with the application itself.
With an understanding of basic browser interactions, we're now equipped to dig deeper into the Todo application. We'll discuss new test assertions and how to interact with forms by creating a todo.
A list of todos is arguably valuable only when the list is owned by one person (or a group of people), but not everyone in the world. In this video, Josh introduces a simple User model and ensures that the todos created are assigned to the person who's "signed in."
We've gone over "Red, Green, Refactor", but haven't performed a larger refactor in the todo codebase. In this video, Josh refactors the controllers to isolate interaction of `session` and introduces a `User` class which mimics a basic authentication library.
Managing a list of tasks to accomplish is great, but you know what's even cooler? Being able to mark things as done. In this video, Josh drives tracking completion of todos through acceptance and unit tests, and covers the intricacies of RESTful actions within the todo application.
Tests are code too, and as such, they can be refactored during the "Refactor" step of "Red, Green, Refactor." In this video, Josh covers how to extract common interactions and assertions in the test suite (having introduced similar paths through todo creation, todo ownership, and todo completion).
What happens when you incorrectly mark a todo complete? You mark it incomplete, of course! In this video, Josh introduces functionality to mark completed todos as incomplete, and refactors the controller to leverage a similar interface to marking a todo as complete.
You've heard about testing, and even better "Test-Driven Development", but you're still not sure exactly what they are. Well now you'll know!
In this trail, thoughtbot developers Harry Schwartz and Ian C. Anderson cover core principles of writing code with Test-Driven Development. You'll learn about the benefits of testing, the way testing first applies positive design pressure to your code, and how to apply TDD to your own development.
You've heard about testing, and even better "Test-Driven Development", but you're still not sure exactly what they are. Well now you'll know! In this trail, thoughtbot developers Harry Schwartz and Ian C. Anderson cover core principles of writing code with Test-Driven Development. You'll learn about the benefits of testing, the way testing first applies positive design pressure to your code, and how to apply TDD to your own development.
Learn the red-green-refactor loop, the primary principle of TDD. Write tests first, watch them fail, write code incrementally until the tests pass. With passing tests, use the opportunity to refactor.
A well-written test case tells a clear story, communicating the intent of code. Learn how to write expressive tests and why duplication isn't always a bad thing in your test cases.
Put your new TDD knowledge into action with this exercise. You'll take an existing spec and whip it into shape, making it clear and purposeful!
Apply the ideas of TDD to a more complicated piece of code. Isolate specific behaviors and build incrementally, using your test failures to guide your next addition to the code.
With a test suite in place, you can refactor with confidence, knowing that your tests will guard against regression. Learn how to leverage your tests while refactoring an existing piece of code.
Integration and unit tests both play important roles in your application's test coverage. Learn when to use each type of tests, guidelines for when to mock collaborators in tests, and how integration and feature tests can drive the creation of unit tests.
Resources for further exploration of Test-Driven Development.
In this screencast, Ben and Chris go back to basics and tackle the first exercise in the Rails Fundamentals trail, "Route, Controller, Action". They create a route, controller, and action using TDD to tell them what to write next.
This episode covers one method of dividing a test into four distinct phases and the benefits of doing so. xUnit Patterns Wiki xUnit Test Patterns book
On this week's episode, Chris is again joined by Josh Clayton, Boston Development Director and TDD master, this time to discuss the power of page objects for cleaning up feature specs.
Joe and Ben discuss the reasons for testing, and how integration and unit testing each serve different reasons. Dive into the benefits of drawbacks of testing at each point in the isolation/integration spectrum by looking through examples.
Joe and Gabe review the four types of test doubles: stubs, mocks, spies and fakes. Learn what the key differences are between each type, as well as when you'd want to consider using them. See examples written using rspec-mocks, as well as an...
Tests are code too, and they deserve the same love and careful refactoring you'd show to your production code. In fact, there are a number of antipatterns and pitfalls unique to test code that can trip you up. Tune in to learn all the dos and...
Recently, we ran a group-coding app-building contest for Upcase subscribers. In this video, Ben and Chris review each of the submissions, both highlighting great aspects and suggesting some areas for improvement. Live code review at its finest!
On this week's episode, Chris is joined by Derek Prior to discuss Rspec's Bisect, a tool to track down order-dependence in your test suite and banish pesky intermittent test failures.
If your application uses third-party APIs, it can be complicated to write good, flexible tests that don't depend on the service being present (or don't touch production data). In this Weekly Iteration, Joël Quenneville and Chris Toomey examine...
Elixir & Phoenix, so hot right now! On this week’s episode we’ll take a look at some of the great features of both Elixir and Phoenix through the lens of Bamboo, a library for sending emails in Phoenix apps, recently released by thoughtbot...
Joël Quenneville presents the why, what, and how of testing in isolation!