Geek Week Update: Day 2
Today was WAAAAY more productive then yesterday, way more, even though I went to bed at 6:30am this morning. I had to finish a project for a client and decided that I better get it out of the way before it started to haunt me and dip into my Wheels time.
The entire day was spent revamping the testing framework for the last time (I hope) as I think I finally got it to where I want it to be. I did a bunch of optimizations to the testrunner and the output display. In doing so I discover the beauty of getComponentMetaData().
When running the tests, I had some logic in place that basically would inspect the meta data of the component you wanted to test to see if it is extending the wheels.test base component. There’s no reason to even waste the time searching for tests to run if the component won’t even have any and the only way it’s going to have tests is if it extends the wheels.test base component.
In order to do the check I would use createobject to create an instance of the component and then use getMetaData() to inspect the meta data. To me this seemed kinda dumb and it bothered me that I knew there had to be a better way and that’s when I found getCompoentMetaData(). Basically this does the same thing as getMetaData() but you don’t have to waste your time instantiating the component. All you have to do is pass the component path to getComponentMetaData() and it does the work for you and returns the exact same meta data that getMetaData() would. Very handy function indeed.
The other thing that was bothering me was the hackery way I was altering the application.wheels.modelPath and the application.wheels.modelComponentPath so that I could call test models with the model() function. Before I was performing my half ass hack inside the test cases themselves in the setup(), but I knew that this was going to get messy. It finally dawned on me to just add them into the testing framework itself for now. Later on we’ll think of a better way to pass a component path to model(), but as for right now this prevents me from having to do the hack manually and even though it’s still a hack, it’s a bit cleaner.
After finally getting the testing framework ironed out, I moved on to refactoring all the tests to get more output and separate the multiple calls to assert() I was doing in each test. All and all, Wheels not has 61 tests in 19 cases. Not bad for a start. It’s definitely NOT where I wanted to be at this point, but there’s no sense in rushing either.
Tonight I ‘m going to do some research into designing a testing database that I can use to properly test the model layer. I’m sure I’ll be totally OCD about the way it’s designed and will spend most of the day second guessing myself over and over. One of the ideas to get around this was was to look at maybe using the blogCFC database since it’s already been ported to like EVERY RDBMS engine out there (go Ray!). We’ll have to see.
Will update again tomorrow.