Misko, the creator of AngularJS (by Google), gives us an overview of how to write testable code and what makes code hard to test.
Misko is the creator of AngularJS and an agile coach at Google.
Psychology of Testability
The Psychology of Testing
2:22:02 - 2:30:00
The three things you need to know about testing. 1: Read the code, 2: Mind your dependencies, 3: Sharpen your environmental Ax. It’s easier to do it properly than do it wrongly.
2:30:00 - 2:38:40
Write Tests First
If you want to test your software, test it at the point of writing. Once it is written, it’s too late.
2:38:40 - 2:49:50
Testing Large and Small Projects
Bigger projects are no harder than small projects - there is just more work. Find the stuff you actually need and then work with them. The more nested the dependencies, the harder things will become for you.
2:49:50 - 2:57:30
Testing Classes and Business Logic
How do you test a class? You test it by replacing the class’s sub-dependencies with ‘friendly’ dummy modules. Then everything that goes wrong is in the class under test. The real sub-dependencies can be plugged back in later.
2:57:30 - 3:06:45
Testing after the fact means you assume the code works, then try it out. The problem is largely insoluble.
3:06:45 - 3:13:30
Testing code vs. Production code
While simple objects can be trusted to be benign, more involved objects need careful handling. The ‘new’ operator is best avoided.
- 2:22:02 - 2:30:00 Testing Fundamentals The three things you need to know about testing. 1: Read the code, 2: Mind your dependencies, 3: Sharpen your environmental Ax. It’s easier to do it properly than do it wrongly.