Commit a2a73f96 authored by Alexander's avatar Alexander
Browse files

Add statistic

parent 44d67156
package final_assignment.task_2;
import edu.kit.informatik.Terminal;
import org.junit.jupiter.api.AfterAll;
import test.TestBase;
import test.TestPair;
import java.io.File;
/**
* This class links the DummyMain of this task and the TestBase
*
......@@ -30,7 +33,40 @@ public class Assignment2TestBase extends TestBase {
testUsingPairs(testPairs, () -> DummyMain.main(args));
}
protected String getDataFolderDirectory() {
protected static String getDataFolderDirectory() {
return "src/final_assignment/task_2/tests/data/";
}
private static int testClassCount = 0;
protected static int getTestClassCount() {
if (testClassCount == 0) {
final File folder = new File(getDataFolderDirectory() + "../");
File[] files = folder.listFiles();
if (files == null) {
return 0;
}
for (final File fileEntry : files) {
if (fileEntry.getName().contains(".java")) {
testClassCount++;
}
}
}
return testClassCount;
}
private static int runCount = 0;
@AfterAll
public static void finish() {
if (++runCount >= getTestClassCount()) {
int sum = numSucceeded + numFailed;
double percentage = (numSucceeded * 100.) / sum;
System.out.printf("You mastered %.2f %% of the %d tests!%n", percentage, sum);
}
}
}
package test;
import edu.kit.informatik.Terminal;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.*;
import java.io.*;
import java.net.NetworkInterface;
......@@ -15,7 +12,6 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
......@@ -48,7 +44,8 @@ public abstract class TestBase {
private long startTime;
private static String userId;
public static final String IO_FILE_COMMAND_LINE_ARGS_PREFIX = "! ";
protected static int numFailed = 0;
protected static int numSucceeded = 0;
/**
* Initializes testing
......@@ -160,6 +157,12 @@ public abstract class TestBase {
*/
@AfterEach
protected void cleanUp(TestInfo testInfo) {
if (testPassed) {
numSucceeded++;
} else {
numFailed++;
}
if (isPerformanceTest && testPassed) {
long endTime = System.nanoTime();
double runTime = ((double) (endTime - startTime)) / 1000000.0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment