Home arrow Tutorials
Tutorials
CSS Selectors and Prototype PDF Print

Most JavaScript libraries provide some form of the $() function. This function is a short hand version of document.getElementById(). However, I was only recently introduced to the $$() function in Prototype. $$() takes a list of CSS selectors and returns an array of objects that match. This ends up being a much easier and more maintainable way to access elements in the DOM than giving EVERYTHING an id. Although the scope of CSS selectors in general is way to large for this tutorial, we will walk thru a simple use of the $$() function in prototype and introduce you to CSS selectors.

Read more...
 
The Concept of Mocking PDF Print
To someone who is new to unit testing, the idea of mock objects can be confusing to say the least. I have covered in previous tutorials how to use various mock object frameworks (EasyMock and jmockit). However in this tutorial, we will focus on the concept of mocking in general. What is a mock object? What is it used for? Why can't I mock object XYZ? Let's look into these questions and maybe clear a bit of the air on the use of mock objects.
Read more...
 
Unit Testing with TestNG and jmockit Part 2 PDF Print
This tutorial is part two in a two part series on TestNG and jmockit. The previous tutorial (found here) covered the classic JUnit and EasyMock scenario, only with TestNG and jmockit. Although you can do that type of testing with these two technologies, that is not their strong point. In this tutorial, we will cover some more advanced features of TestNG and use jmockit's ability to "remap" a class in your JVM to handle a more robust suite of testing scenarios.
Read more...
 
Unit Testing with TestNG and jmockit PDF Print
TestNG is a testing framework for unit test development. jmockit is a framework for mock objects that provides mock object functionality using the java.lang.instrument package of jdk 1.5. Together, these frameworks can provide the tools to create very robust test cases without design limitations of other testing frameworks currently available. In part one of this two part tutorial, we will cover the creation of a test case and the implementation of the related class to be tested. We will reuse the same scenario as in my tutorial: Unit testing with JUnit and EasyMock. If you are new to unit testing in general, I suggest you check out the JUnit tutorial as well for it's section on unit testing in general. In part two, we will cover scenarios that favor the TestNG and jmockit frameworks including testing using mocks without injection and organizing tests into groups.
Read more...
 
Unit testing with JUnit and EasyMock PDF Print
We all have it. It's that piece of code in our project that everyone is afraid to change. It's so confusing no one truly understands what is going on. We are all afraid that if we do change it, we'll break it. You have just discovered my favorite reason for writing unit tests. But how do you write a unit test? What exactly is a unit test? How do I handle dependencies? And how is writing more code going to make my existing code better? This tutorial will show you how.
Read more...