Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/kataAnalyzer/testProcessor/UnitTestProcessor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package kataAnalyzer.testProcessor;

import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -10,7 +14,12 @@ public class UnitTestProcessor {
UnitTestRunner testRunner = new UnitTestRunner();
UnitTestResultsAnalyzer testResultsAnalyzer = new UnitTestResultsAnalyzer();

public boolean process(List<String> testFiles, String path) {
public boolean process(List<File> fileList, String path) {
List<String> testFiles = new ArrayList<>();

for ( int i = 0; i < fileList.size(); i++) {
testFiles.add(FilenameUtils.removeExtension(fileList.get(i).getName()));
}

boolean unitTestsPassed = true;

Expand Down
16 changes: 10 additions & 6 deletions srcTest/kataAnalyzer/testProcessor/UnitTestProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.util.List;
import java.util.ArrayList;
import org.junit.Assert;
Expand All @@ -12,16 +14,18 @@
public class UnitTestProcessorTest {

UnitTestProcessor testProcessor;
List<String> testFiles;
List<File> testFiles;
final String testClassPath = "../../out/test/kataAnalyzer";
File successFile = new File(testClassPath + "/SuccessTests.class");
File failFile = new File(testClassPath + "/FailureTests.class");

@Before
public void getUnitTestProcessor() {
testProcessor = new UnitTestProcessor();
}
@Before
public void getTestFilesList() {
testFiles = new ArrayList<String>();
testFiles = new ArrayList<>();
}

@Test
Expand All @@ -31,17 +35,17 @@ public void itReturnsFalseWhenNoTestFilesArePassed() {

@Test
public void itReturnsTrueWhenAllTestFilesPass() {
testFiles.add("SuccessTests");
testFiles.add("SuccessTests");
testFiles.add(successFile);
testFiles.add(successFile);

Assert.assertTrue( testProcessor.process(testFiles, testClassPath) );

}

@Test
public void itReturnsFalseWhenAnyTestFileFails() {
testFiles.add("FailureTest");
testFiles.add("SuccessTest");
testFiles.add(failFile);
testFiles.add(successFile);

Assert.assertFalse( testProcessor.process(testFiles, testClassPath) );
}
Expand Down