Home arrow Tutorials
Tutorials
How to Mock Static Methods PDF Print
We have all read it or heard someone talk about it. "Static Methods are Death to Testability". You can read the article here: http://bit.ly/4mk3fP. Something that has become a fundimental piece of the language (all you need to do is look at the Apache Commons project to see that) is so bad that it must be avoided at all costs in the name of testing. Gosling (or someone on his team) put it in the language for a reason and to avoid those uses solely because your toolset doesn't support the testing of it is nonsense. Time to get a new toolset. In this tutorial we will cover how to mock static methods (*gasp) using PowerMock.
Read more...
 
Mock Controls with EasyMock PDF Print
Most people who have used EasyMock before are familiar with the types of mock objects. There is the basic mock object, created with EasyMock.createMock(MyInterface.class). There is the strict mock that validates both the method calls and the order they occur. Finally there is the nice mock which returns a basic default (false, 0 or null) if an unexpected method call occurs. However, most developers I have come across don't use mock controls much. This tutorial will introduce you to the concepts of mock controls and show you an example of where testing without them may not be as safe as you think.
Read more...
 
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...
 

Tweets

    Twitter Button from twitbuttons.com