Skip to content

Commit

Permalink
Add mmore result value types to distinguish tests that do not matter.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY committed Dec 3, 2024
1 parent b986f72 commit a9e49b6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
* An absctract basis of a TextTestWriter, which outputs in a human readable format, into console.
Expand Down Expand Up @@ -89,7 +87,9 @@ private String testString(Test t, String prefix, int index) {
out.append(String.format(widthSpec, desc));
out.append(" ┃ ");
Colors.Foreground valueColor;
if (result.getValue().ok()) {
if (result.getValue().equals(Result.Value.OKSUCCESS) || result.getValue().equals(Result.Value.OKFAILURE)) {
valueColor = Colors.Foreground.WHITE;
} else if (result.getValue().ok()) {
valueColor = Colors.Foreground.GREEN;
} else if (result.getValue().equals(Result.Value.ERROR)) {
valueColor = Colors.Foreground.RED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CompoundTest extends Test implements Cloneable {

public final static Consumer<Test[]> RUN_ALL_IF_FIRST = tests -> {
tests[0].run();
if (tests[0].getResult().getValue().equals(Result.Value.SUCCESS) || tests[0].getResult().getValue().equals(Result.Value.UXSUCCESS)) {
if (tests[0].getResult().getValue().successful()) {
for (int i = 1; i < tests.length; i++) {
tests[i].run();
}
Expand Down
26 changes: 17 additions & 9 deletions common/src/main/java/cz/crcs/ectester/common/test/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ public boolean compareTo(Value other) {
* A result value of a Test.
*/
public enum Value {
SUCCESS(true, "Expected success."),
FAILURE(false, "Unexpected failure."),
UXSUCCESS(false, "Unexpected success."),
XFAILURE(true, "Expected failure."),
ERROR(false, "Error.");
SUCCESS(true, true, "Expected success."),
FAILURE(false, false, "Unexpected failure."),
UXSUCCESS(false, true, "Unexpected success."),
XFAILURE(true, false, "Expected failure."),
OKSUCCESS(true, true, "Any result is OK."),
OKFAILURE(true, false, "Any result is OK."),
ERROR(false, false, "Error.");

private boolean ok;
private boolean successful;
private String desc;

Value(boolean ok) {
Value(boolean ok, boolean successful) {
this.ok = ok;
this.successful = successful;
}

Value(boolean ok, String desc) {
this(ok);
Value(boolean ok, boolean successful, String desc) {
this(ok, successful);
this.desc = desc;
}

Expand All @@ -74,7 +78,7 @@ public static Value fromExpected(ExpectedValue expected, boolean successful) {
case FAILURE:
return successful ? UXSUCCESS : XFAILURE;
case ANY:
return successful ? SUCCESS : XFAILURE;
return successful ? OKSUCCESS : OKFAILURE;
}
return SUCCESS;
}
Expand All @@ -90,6 +94,10 @@ public boolean ok() {
return ok;
}

public boolean successful() {
return successful;
}

public String description() {
return desc;
}
Expand Down

0 comments on commit a9e49b6

Please sign in to comment.