// build the project, wait until tests are running, then cancel.
project.scheduleBuild(0);
Thread.sleep(2000);
FreeStyleBuild b = project.getLastBuild();
b.doStop(
EasyMock.createNiceMock(StaplerRequest.class),
EasyMock.createNiceMock(StaplerResponse.class));
Thread.sleep(1000);