Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When/how frequently should I test?

Tags:

testing

As a novice developer who is getting into the rhythm of my first professional project, I'm trying to develop good habits as soon as possible. However, I've found that I often forget to test, put it off, or do a whole bunch of tests at the end of a build instead of one at a time.

My question is what rhythm do you like to get into when working on large projects, and where testing fits into it.

like image 367
btw Avatar asked Dec 22 '22 14:12

btw


2 Answers

Well, if you want to follow the TDD guys, before you start to code ;)

I am very much in the same position as you. I want to get more into testing, but I am currently in a position where we are working to "get the code out" rather than "get the code out right" which scares the crap out of me. So I am slowly trying to integrate testing processes in my development cycle.

Currently, I test as I code, trying to bust the code as I write it. I do find it hard to get into the TDD mindset.. Its taking time, but that is the way I would want to work..

EDIT:

I thought I should probably expand on this, this is my basic "working process"...

  1. Plan what I want from the code, possible object design, whatever.
  2. Create my first class, add a huge comment to the top outlining what my "vision" for the class is.
  3. Outline the basic test scenarios.. These will basically become the unit tests.
  4. Create my first method.. Also writing a short comment explaining how it is expected to work.
  5. Write an automated test to see if it does what I expect.
  6. Repeat steps 4-6 for each method (note the automated tests are in a huge list that runs on F5).
  7. I then create some beefy tests to emulate the class in the working environment, obviously fixing any issues.
  8. If any new bugs come to light following this, I then go back and write the new test in, make sure it fails (this also serves as proof-of-concept for the bug) then fix it..

I hope that helps.. Open to comments on how to improve this, as I said it is a concern of mine..

like image 125
Rob Cooper Avatar answered Jan 17 '23 08:01

Rob Cooper


Before you check the code in.

like image 36
N8g Avatar answered Jan 17 '23 10:01

N8g