"The Clean Code Talks -- Unit Testing"
Why Stack Overflow recommends it
Stack Overflow users link it when someone asks about unit testing, mocking, dependency injection or why their code is hard to test, since it explains designing for testability.
Recommended by 21 people across 20 different months, 2008 to 2017.
Why Software Engineering Stack Exchange recommends it
Software Engineering Stack Exchange users link it when explaining how testability drives design, and to back up rules like avoiding `new` in business logic and doing little work in constructors.
Recommended by 2 people across 2 different months, 2011 to 2017.
Why Code Review Stack Exchange recommends it
Code Review Stack Exchange users point people to it when reviewing code that is hard to test or that hides its dependencies, and when explaining dependency injection.
Recommended by 2 people across 1 different months, 2013 to 2014.
What it is
A 32-minute Google Tech Talk from 2008 in which Misko Hevery, then at Google, explains how to write code that is easy to unit test. It covers dependency injection, separating object creation from business logic, avoiding statics and globals, and using seams so dependencies can be mocked. It is the unit testing entry in his Clean Code Talks series.
What people said
Strong rec chickeninabiscuit · 2010-06 · Stack Overflow · on “Dependency Injection, IoC and Mocking finally explained in a simple and understandable way!”
I found this talk really helpful for understanding how dependency injection benefits testing: "The Clean Code Talks -- Unit Testing" [this video]
Strong rec tereško · 2012-07 · Stack Overflow · on “PHP MVC, view loop handling”
@SheikhHeera , if you really want to understand MVC, then you should start by focusing on researching OOP (just because you know how to write class, does not mean that you undersstand OOP). I would recommend to start with reading everything you can find about *SOLID principles*. Also lectures from Miško Hevery [this video] (first one is irrelevant) and Robert C. Martin are very recommended.
Strong rec Steven Doggart · 2013-07 · Code Review Stack Exchange · on “"Fancy-pants" vs "Cowboy" coding”
If you are interested in learning about DI, do a search for some of Misko Hevery's Google Talk presentations on the subject. I really got a lot out of watching those back when I first started getting into it. For instance, all of these are great: [this video]
Recommends Nazgob · 2008-11 · Stack Overflow · on “How much null checking is enough?”
NULL checking in general is evil as it's add a small negative token to the code testability. With NULL checks everywhere you can't use "pass null" technique and it will hit you when unit testing. It's better to have unit test for the method than null check. Check out decent presentation on that issue and unit testing in general by Misko Hevery at [this video]
Recommends Drejc · 2009-01 · Stack Overflow · on “Unit-testing private methods: Facade pattern”
Maybe if you take time and look the Clean Code Tech talks [this video] from Miško. He is very insightfull of how code should be written in order to be tested.
Recommends cwash · 2009-06 · Stack Overflow · on “Testing approach for algorithms with complex outputs”
I think the answer to the question you're asking boils down to designing for testability. Often you get a testable design for free when you test-drive the development of the solution. But let's face it, when you're implementing a highly mathematical algorithm, this just doesn't fall out. To make sure you have a testable design, you need to understand what a seam is. Then you need to know a few rules of thumb, such as avoiding statics, using polymorphism, and properly decomposing problems and separating concerns. Watch "The Clean Code Talks -- Unit Testing" by Misko Hevery [this video] , I think it will help you wrap your head around it.
Recommends ratkok · 2010-06 · Stack Overflow · on “Simplifying Testing through design considerations while utilizing dependency injection”
Here are some good links about DI and good design practices (in terms of writing testable code) that you might want to check (google tech talks): Clean Code Talks - Don't Look For Things! [this video] Clean Code Talks - "Global State and Singletons" [LINK] Clean Code Talks - "GuiceBerry" [LINK] I found them very helpful with plenty of good tips on testable design.
Recommends Doc Brown · 2010-07 · Stack Overflow · on “Dependency injection: do we all need to know that?”
Here is a really nice reference why Dependency injection is crucial for writing (unit) testable code: [this video] (The Clean Code Talks -- Unit Testing)
Recommends Alex Peck · 2010-08 · Stack Overflow · on “Tutorial for Unit Testing with VS 2010”
If you are new to unit testing, in addition to learning the tools, I would recommend learning a bit about how to write testable code. E.g. using dependency injection and abstraction as a test seam. This video goes over the basics: [this video] . It is more at the conceptual level than being a tutorial, but nevertheless is well worth watching.
Recommends hidralisk · 2010-08 · Stack Overflow · on “Testing methodologies”
In the order of most commonly used approach: no tests at all manual tests: running the app, clicking or providing input, check results try to write some JUnits, forget about them, slide to 2 and 1 Start with TDD, see that it's hard then slide to 3, 2 and 1 on the theoretical side there are loads of ways to properly test the code. If you are looking for something practical take a look at Clean Code Talk [this video] . Take a look at the whole series, about 5 talks (can't post more than one link).