Tuesday, September 15, 2015

Test Double Patterns

Some time ago I wrote an article about the consequences of using Test Double, but there was nothing about Test Double Patterns, nothing more than a simple list. Today I would like to change it and explain the differences between those patterns.

As I wrote in mentioned article that:
Test Double are patterns that allow us to control dependencies between the tested unit. To make it possible to provide wanted behavior whenever we want to or/and verify whether wanted behavior occurred.
So now when you have been reminded of the basics, we can move to the interesting part - let’s look at Test Double Patterns.

Wednesday, September 9, 2015

main method should not be your test strategy

Nowadays many developers know about advantages of tests. We know how they’re helping us when we need to change or refactor the code. We also know how helpful they can be when we want to describe or show how a particular functionality works.
We are encouraging to write tests. To cover your code. To decrease uncertainty.

Yet, I’m still seeing a lot of articles where someone shares his knowledge about particular features and… he shows how the code works using main() method:
public class WhateverApp {
    public static void main(String[] args) {
        DescribedFunctionalityProvider provider = new DescribedFunctionalityProvider();
       
        Result result = provider.showHowYouDoingThings();
 
        System.out.println(result.showThatReallyWorks());
    }
}

I’ve got one simple question – why?