Skip to content

Commit

Permalink
Code review requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ldeck committed Dec 6, 2017
1 parent 30dcbb7 commit 0798524
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,20 @@ public RemoteWebDriver getWebDriver() {

@Override
protected void failed(Throwable e, Description description) {

switch (recordingMode) {
case RECORD_FAILING:
case RECORD_ALL:
stopAndRetainRecording(description, false);
stopAndRetainRecordingForDescriptionAndSuccessState(description, false);
break;
}
currentVncRecordings.clear();
}

@Override
protected void succeeded(Description description) {

switch (recordingMode) {
case RECORD_ALL:
stopAndRetainRecording(description, true);
stopAndRetainRecordingForDescriptionAndSuccessState(description, true);
break;
}
currentVncRecordings.clear();
Expand All @@ -211,7 +209,7 @@ protected void finished(Description description) {
this.stop();
}

private void stopAndRetainRecording(Description description, boolean succeeded) {
private void stopAndRetainRecordingForDescriptionAndSuccessState(Description description, boolean succeeded) {
File recordingFile = recordingFileFactory.recordingFileForTest(vncRecordingDirectory, description, succeeded);
LOGGER.info("Screen recordings for test {} will be stored at: {}", description.getDisplayName(), recordingFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
public class DefaultRecordingFileFactory implements RecordingFileFactory {

private static final SimpleDateFormat filenameDateFormat = new SimpleDateFormat("YYYYMMdd-HHmmss");
private static final String PASSED = "PASSED";
private static final String FAILED = "FAILED";
private static final String FILENAME_FORMAT = "%s-%s-%s-%s.flv";

@Override
public File recordingFileForTest(File vncRecordingDirectory, Description description, boolean succeeded) {
final String prefix = succeeded ? "PASSED" : "FAILED";
final String fileName = String.format("%s-%s-%s-%s.flv",
final String prefix = succeeded ? PASSED : FAILED;
final String fileName = String.format(FILENAME_FORMAT,
prefix,
description.getTestClass().getSimpleName(),
description.getMethodName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Random;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
Expand All @@ -33,10 +32,9 @@ public class DefaultRecordingFileFactoryTest {

@Parameterized.Parameters
public static Collection<Object[]> data() {
Random random = new Random();
Collection<Object[]> args = new ArrayList<>();
args.add(new Object[]{format("testMethodName%d", random.nextInt()), "FAILED", FALSE});
args.add(new Object[]{format("testMethodName%d", random.nextInt()), "PASSED", TRUE});
args.add(new Object[]{"testMethod1", "FAILED", FALSE});
args.add(new Object[]{"testMethod2", "PASSED", TRUE});
return args;
}

Expand Down

0 comments on commit 0798524

Please sign in to comment.