Skip to content

Commit

Permalink
Fixing flacky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Raquel Pau committed Nov 12, 2017
1 parent 55eece8 commit be38b87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 11 additions & 3 deletions src/main/java/org/walkmod/junit4git/junit4/Junit4GitRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ public Junit4GitRunner(Class<?> klass) throws InitializationError {
}

protected void setUpListener(RunNotifier notifier) {
if (listener != null) {
notifier.addListener(listener);
listener = null;
if (getListener() != null) {
notifier.addListener(getListener());
removeListener();
}
}

protected Junit4GitListener getListener() {
return listener;
}

protected void removeListener() {
listener = null;
}

@Override
public void run(RunNotifier notifier) {
setUpListener(notifier);
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/org/walkmod/junit4git/jgit/GitRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -102,7 +101,7 @@ protected void init() {
}
}

public void delete() throws IOException {
FileUtils.deleteDirectory(path.toFile());
public void delete() {
FileUtils.deleteQuietly(path.toFile());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
public class Junit4GitRunnerTest {

@Test
public void adds_listener() throws Exception {
public void it_updates_notifier() throws Exception {
Junit4GitRunner runner = new Junit4GitRunner(Foo.class);
RunNotifier notifier = mock(RunNotifier.class);
runner.run(notifier);
verify(notifier).addListener(any(Junit4GitListener.class));
verify(notifier).fireTestRunStarted(any());
}

Expand Down

0 comments on commit be38b87

Please sign in to comment.