Browse Source

TestFramework add testColor to TestUnit and TestSuite

JNI-96
heck 5 years ago
parent
commit
a856100e24
  1. 11
      test/java/foundation/pEp/jniadapter/test/framework/TestSuite.java
  2. 13
      test/java/foundation/pEp/jniadapter/test/framework/TestUnit.java

11
test/java/foundation/pEp/jniadapter/test/framework/TestSuite.java

@ -7,6 +7,7 @@ import java.util.ArrayList;
public class TestSuite {
private static ArrayList<TestUnit> tests = new ArrayList<TestUnit>();
private static boolean verbose = false;
private static TermColor testColor = TermColor.CYAN;
private TestSuite() { }
@ -18,6 +19,15 @@ public class TestSuite {
verbose = v;
}
public static TermColor getTestColor() {
return testColor;
}
public static void setTestColor(TermColor color) {
testColor = color;
}
public static void add(TestUnit t) {
tests.add(t);
}
@ -25,6 +35,7 @@ public class TestSuite {
public static void run() {
for (TestUnit t : tests) {
t.setVerboseMode(verbose);
t.setTestColor(testColor);
t.run();
}
printStats();

13
test/java/foundation/pEp/jniadapter/test/framework/TestUnit.java

@ -16,6 +16,7 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
private Throwable lastException;
private boolean verboseMode = true;
private TermColor testColor = TermColor.CYAN;
// Defaults (line width 80)
private int logFmtTestNameLen = 35;
@ -37,6 +38,14 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
this.verboseMode = verboseMode;
}
public TermColor getTestColor() {
return testColor;
}
public void setTestColor(TermColor testColor) {
this.testColor = testColor;
}
public TestResult getResult() {
return result;
}
@ -64,7 +73,7 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
//Context init problems need to throw to fail
try {
setTestState(TestState.CTX_INIT);
setTermColor(TermColor.BLUE);
setTermColor(testColor);
ctx.init();
setTermColor(TermColor.RESET);
} catch (Throwable t) {
@ -78,7 +87,7 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
}
//tests need to throw to fail
setTestState(TestState.RUNNING);
setTermColor(TermColor.CYAN);
setTermColor(testColor);
lambda.accept(ctx);
setTermColor(TermColor.RESET);
setTestState(TestState.SUCCESS);

Loading…
Cancel
Save