diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-03-19 01:55:01 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-03-19 02:14:24 +0100 |
commit | dcb7efcc0e3da57d2a6e0b8ab6f30bc5f027ee11 (patch) | |
tree | 02045edc909a91e5e4b33486eb452b93726feb32 /src/support/lombok | |
parent | 0c6a243c8ec7ef7a1a432b17cd865a1f54a3b827 (diff) | |
download | lombok-dcb7efcc0e3da57d2a6e0b8ab6f30bc5f027ee11.tar.gz lombok-dcb7efcc0e3da57d2a6e0b8ab6f30bc5f027ee11.tar.bz2 lombok-dcb7efcc0e3da57d2a6e0b8ab6f30bc5f027ee11.zip |
[testing] improve the output of `ant test`.
Diffstat (limited to 'src/support/lombok')
-rw-r--r-- | src/support/lombok/ant/SimpleTestFormatter.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/support/lombok/ant/SimpleTestFormatter.java b/src/support/lombok/ant/SimpleTestFormatter.java new file mode 100644 index 00000000..2f605d06 --- /dev/null +++ b/src/support/lombok/ant/SimpleTestFormatter.java @@ -0,0 +1,61 @@ +package lombok.ant; + +import java.io.OutputStream; +import java.io.PrintStream; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; + +public class SimpleTestFormatter implements JUnitResultFormatter { + private PrintStream out = System.out; + + @Override + public void addError(Test test, Throwable error) { + logResult(test, "ERR"); + out.println(error.getMessage()); + } + + @Override + public void addFailure(Test test, AssertionFailedError failure) { + logResult(test, "FAIL"); + out.println(failure.getMessage()); + } + + @Override + public void endTest(Test test) { + logResult(test, "PASS"); + } + + @Override + public void startTest(Test test) { } + + @Override + public void endTestSuite(JUnitTest testSuite) throws BuildException { } + + @Override + public void setOutput(OutputStream out) { + this.out = new PrintStream(out); + } + + @Override + public void setSystemError(String err) { + // don't echo test error output + } + + @Override + public void setSystemOutput(String out) { + // don't echo test output + } + + @Override + public void startTestSuite(JUnitTest testSuite) throws BuildException { } + + private void logResult(Test test, String result) { + out.println("[" + result + "] " + String.valueOf(test)); + out.flush(); + } +} |