This is usually a blog for the family, but this is a topic I need to write about, and I apologize to them for that. So, if you’re family reading this, it’s ok to quit reading now, boredom will ensue!
It’s taken me a little longer than expected but I think I am getting the hang of unit testing… or at least the idea of it, I still don’t implement it as much as my boss would like. The more I look at it the more Unit Testing makes sense, but there is one huge hang up. When you design a test, you have to take into account that data changes. I have been doing and seeing a lot of instances where the tests have hardcoded values in them. This poses a huge problem when the data has to be wiped and a fresh start is required or if the data simply changes. It causes daily builds to fail and then you’re stuck fixing the test when the application is just fine so you can get rid of the nagging messages saying that the build is broken. This is just a waste of time.
Unit testing is a building process, just like software development. You have to start at ground zero with ambiguous methods to get data and to get the data you need. From there you can create more complex tests and have them not be dependent on specific values, because the methods have been created for you to use to get the data; specific values are not good.
It is still hard for me to start with the tests and build the software from there as Test Driven Development (TDD) entails. Then, after you have data manipulation mastered you can start on the user interface. That is not the way I was programmed. This requires forward thinking and a knowledge of how the program is supposed to work. I was taught to start with the user interface (because that is what the user sees) and make the software work the way the user wants to see it. This has led to some clunky programs (Matt, if you’re reading this… HUSH)!
I can see where Unit Testing and TDD come together to create clean, and in some ways more simple, back ends to applications, the trouble for me is the thinking part.
No comments:
Post a Comment