View Full Version : Junit testing for a state design pattern

04-08-2012, 12:44 AM
Hi there,

I'd like write a Junit test program for a 'state' design pattern but don't really know what to do. I've tried looking on the web/books to try and find similar examples for ideas but they are either not relevant or too advanced for my purposes.

Here's what I've done so far, which as you can see isn't much. Since it's not complete, unsurprisingly it doesn't run. I get a java.lang.NullPointerException compile time error.

package TCPProtocol;

import static org.junit.Assert.*;

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

* @author
public class TCPConnectionTest {

public void setUp() throws Exception {

@Test(timeout = 4000) // fail if passed 4000ms
public void test() {
TCPConnection tcpconnection = new TCPConnection();


Sorry if this seems like a stupid question. I'm new to this stuff and Iím really at my wits end. The above code on its own probably doesnít help much so please let me know what else you need.

Anyway, I hope you can help.

Many thanks,

C :)