DEV Community


Discussion on: When do you write your tests?

ben profile image
Ben Halpern

When my environment is set up well to do so, I usually write my tests as I code. Some come before I write the code, some come after. It really depends on how the flow goes. If I'm creating a new class I might:

  • Create the class file
  • Then create an accompanying test file
  • I'll think of the first public method I want to write and write the test for it's basic case

Then everything from there is a back and forth of varying order. My flows have been getting more structured lately so I could see eventually doing strict TDD.