testdriven.com Wrangling quality out of chaos

Archive for November, 2007

JEasyTest is released

11.18.2007 · Posted in Tools

JEasyTest is an Eclipse plugin created to simplify unit testing of code that is hard to test using standard mock objects frameworks.
JEasyTest uses AspectJ load-time bytecode modification "to inject mock invocations" (constructor and static method invocations) where we could not using standard mock object tools.
JEasyTest has been thought to be integrated with existing mock object frameworks to overcome some of their limitations.
The new release adds Eclipse 3.3 support, JUnit4 support, an Ant task and an improved API.
In JEasyTest the bytecode is modified only at runtime just before test running, without any possibility that production code might contain unwanted testing code. Thanks to the Eclipse plugin nature, JEasyTest usage of AspectJ is completely hidden and it happens behind the scenes while we are writing tests.

Here is a simple example of test written using JEasyTest:

Code:
@ClassUnderTest(MyServiceClient.class)
public class MyServiceClientTest {
@JEasyTest
@org.junit.Test
public void runThrowsIllegalStateExceptionIfInitialContextThrowsNamingException() throws Exception {
on(System.class).expectStaticNonVoidMethod("getProperty").with(arg("objectName")).andReturn("test");
on(InitialContext.class).expectEmptyConstructor().andThrow(new NamingException("message"));

MyServiceClient client = new MyServiceClient();
try {
client.run();
fail(IllegalStateException.class+" should have been thrown");
} catch (IllegalStateException e) {
assertEquals("message", e.getMessage());
}
}
}

where

public class MyServiceClient {
public void run() {
String objectName = System.getProperty("objectName");
if (objectName == null){
throw new IllegalStateException("Object name system property must be defined");
}
try {
InitialContext context = new InitialContext();
Service service = (Service)context.lookup(objectName);
service.doThis();
} catch (NamingException e) {
throw new IllegalStateException(e.getMessage());
}
}
}

Lean Configuration Management – Evolving the CM Discipline Through the Agile Paradigm Shift

11.02.2007 · Posted in Links

The increasing popularity of agile development methods is putting new demands on the traditional CM discipline. A working CM environment is essential for the rapid nature of agile development methods, but the CM process and the CM role has to be adapted to the present evolution of software development methods as well as automated tools. This article discusses lean principles and agile values within a CM scope and also introduces a method to classify the CM discipline in relation to development method and level of tool automation.
link

Tags:

MockFtpServer is released

11.02.2007 · Posted in News

The MockFtpServer project provides a mock/dummy FTP server for testing FTP client code. It can be configured to return custom data or reply codes, to simulate either success or failure scenarios. Expected command invocations can also be verified.

MockFtpServer is written in Java, and is ideally suited to testing Java code. But because communication with the FTP server is across sockets and TCP/IP, it can be used to test FTP client code written in any language.