-
Notifications
You must be signed in to change notification settings - Fork 54
Intro to TDD
Testing is a fundamental part of the software development cycle. It is important to test to ensure that our system is working as expected.
Testing happens at multiple different stages of our application development and we can structure the different types of test we do into a pyramid that signifies the different levels.
There are several 'patterns' and 'antipatterns' to consider when approaching your tests. Check out all these pyramids!
The og. test pyramid was a concept of Mike Cohn
The top benefits and take-aways from this approach are:
- Write tests with different granularity
- The more high-level you get the fewer tests you should have
Unit testing targets small, isolated chunks of code eg. a function.
They are easy to implement, quick to run and give very specific feedback.
The majority of your testing should be based around unit tests.
Other terms you may hear for tests around this level are "Integration", "API" and more.
These tests start to bring together units and test them as a group.
Other terms you may hear for tests around this level are "System", "Behaviour" and more.
This is where your complete program will start to be tested to find the end result.
The highest level of testing, usually done manually.
Consider the ice-cream cone antipattern next to this lovely volcano pyramid. What issues could this bring?
Test Driven Development is an approach where we write failing tests first and then work to get them passing. This means that you will be writing tests very early in your development process if using TDD. Testing does automatically equal TDD.
There is a plethora of testing frameworks available for you to choose from including:
Mocha | Tape | Jasmine | Jest and many more...
Check out our walkthroughs for setting up JS Unit tests with two options:
For more information on our transformative coding education, visit us at https://www.lafosseacademy.com/