package org.ale.app;

import static org.junit.Assert.assertEquals;

import org.junit.Test;


public class TwitterLinkCreatorTest {

	@Test
	public void shouldProcessSingleTwitterName() {
		String result = TwitterLinkCreator.process("@foobar");
		assertEquals("<a href=\"http://twitter.com/foobar\">@foobar</a>", result);
	}
	
	@Test
	public void shouldProcessSeveralTwitterNames() {
		String result = TwitterLinkCreator.process("@foo, @bar");
		assertEquals("<a href=\"http://twitter.com/foo\">@foo</a>, <a href=\"http://twitter.com/bar\">@bar</a>", result);
	}
	
	@Test
	public void shouldProcessNameWithUnderscore() {
		String result = TwitterLinkCreator.process("@foo_bar");
		assertEquals("<a href=\"http://twitter.com/foo_bar\">@foo_bar</a>", result);
	}
}

package org.ale.app;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;


public class TwitterLinkCreatorTest {

    private String twitterAddress;

    @Before
    public void setup(){
        twitterAddress = "<a href=\"http://twitter.com/";
    }

    @Test
	public void shouldProcessSingleTwitterName() {
        String result = TwitterLinkCreator.process("@foobar");

        assertEquals(twitterAddress +"foobar\">@foobar</a>", result);
	}
	
	@Test
	public void shouldProcessSeveralTwitterNames() {
		String result = TwitterLinkCreator.process("@foo, @bar");

        assertEquals(twitterAddress +"foo\">@foo</a>, <a href=\"http://twitter.com/"+"bar\">@bar</a>", result);
	}
	
	@Test
	public void shouldProcessNameWithUnderscore() {
		String result = TwitterLinkCreator.process("@foo_bar");

        assertEquals(twitterAddress +"foo_bar\">@foo_bar</a>", result);
	}
}

Refactor tests: Extracted the twitter address to a field
Refactor tests: Extracted the twitter address to a field
