DEV Community

Discussion on: Why You Should Be Unit Testing

markschweiger15 profile image
Mark Schweiger

Very nice.
Do you write your unit tests before (TDD) or after the code is written?
Also, do you prefer mocking dependencies or integration tests?

restoreddev profile image
Andrew Davis Author

I don’t do TDD religiously, but I’m trying to move in that direction. Writing the test before code makes you write your code in a more testable way.

Typically I will mock and do integration. I like mocking when I’m testing a small piece of functionality and I want to mock away another dependency so I don’t have to worry about it. But then I’ll have an integration to make sure it all works together.