I've been working with Jasmine to test my client side code, however, my code extends beyond the client. I am working on server side JavaScript using Node.js. It would be great to apply my test driven process to my node server as well. Luckily, the Node community is large, helpful, and talented. Jasmine has been ported to the server with the jasmine-node project by Miško Hevery (https://github.com/mhevery/jasmine-node). The github readme summarizes the process of setting up jasmine-node, so this post will expound on those points.
12/31/2012
12/17/2012
Building a Unit Test in Jasmine, Part 4
The last part in this series is going to involve some time travel. Physics
aside, let's assume six months have passed since our original JasmineTester
object was created. The object was a great success and has been embedded
all throughout the organization. We have forgotten the details of our
earlier work as multiple other projects have come and gone. While still
basking in the glow of our earlier success, a new requirement comes down the
line: make a new object exactly like the JasmineTester but with multiplication. Thanks
goodness we used Jasmine!
12/03/2012
Building a Unit Test in Jasmine, Part 3
We created a Jasmine unit test example in the first two parts of this series that started with a statement and then abstracted out to an object. This time we will expand the object to be more robust. Most importantly, we are not changing the tests currently in place.
The JasmineTester is going to be updated to accept a random number of values. The first step is to create a unit test to describe this. The number of properties being added is upped to 4. The new test will check to make sure the new object constructor still returns an object by using the toBeDefined matcher.
The JasmineTester is going to be updated to accept a random number of values. The first step is to create a unit test to describe this. The number of properties being added is upped to 4. The new test will check to make sure the new object constructor still returns an object by using the toBeDefined matcher.
11/27/2012
Solve the Problem, Not the Behavior
In my past life of consultancy I became very used to working on other people's code. One of the most important lessons I learned was to "find the problem first". Errors are a behavior you witness. Debugging is fixing those errors. Most developers would consider those reasonable statements. There is an underhanded trick here though. Some developers might make the mistake of a direct connection between the two, but there isn't. The error you witness may not be the error you need to fix.
11/26/2012
Building a Unit Test in Jasmine, Part 2
In the previous part, I showed an extremely simple test whose only purpose is to highlight how Jasmine works. This post will take those pieces and start doing something more dynamic with our source code. The Source and the Spec are going to change.
One reason to unit test is to confirm your code works despite internal changes to the source. As your application changes and matures, it can be daunting to ensure your old code still works. Properly created and maintained unit tests make this much less scary. You add a feature, run all your tests. Everything passes, then you are in good shape. If something breaks, you know it now and not when the customer finds it. Once everything passes you can move on to your next set of changes with relative certainty your application still works. This post will set us up to show that principle in action over the next 2 posts.
One reason to unit test is to confirm your code works despite internal changes to the source. As your application changes and matures, it can be daunting to ensure your old code still works. Properly created and maintained unit tests make this much less scary. You add a feature, run all your tests. Everything passes, then you are in good shape. If something breaks, you know it now and not when the customer finds it. Once everything passes you can move on to your next set of changes with relative certainty your application still works. This post will set us up to show that principle in action over the next 2 posts.
Subscribe to:
Posts (Atom)