@Test
public void testWaitForBuildToFinish() throws InterruptedException {

    MockProject mockProject = new MockProject() {
        private static final long serialVersionUID = -8172748698812254496L;
        public void run() {
            loop();
        }
        void checkWait() throws InterruptedException {
            waitForBuildToFinish();
        }
    };
    new Thread(mockProject).start();
    Thread.sleep(100);
    assertEquals(1, mockProject.getLoopCount());
    Thread.sleep(100);
    assertEquals(1, mockProject.getLoopCount());
    mockProject.buildFinished();
    Thread.sleep(100);
    assertEquals(2, mockProject.getLoopCount());
    mockProject.stopLooping();
}