Last active
April 4, 2021 09:02
-
-
Save mehmetcemyucel/c4b692786826d019cce0718eddf5e322 to your computer and use it in GitHub Desktop.
springboot-junit-rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TestWatcherTest { | |
| private static String watchedLog; | |
| @Rule | |
| public final TestRule watchman = new TestWatcher() { | |
| @Override | |
| public Statement apply(Statement base, Description description) { | |
| return super.apply(base, description); | |
| } | |
| @Override | |
| protected void succeeded(Description description) { | |
| watchedLog += description.getDisplayName() + " " + "success!\n"; | |
| } | |
| @Override | |
| protected void failed(Throwable e, Description description) { | |
| watchedLog += description.getDisplayName() + " " + e.getClass() | |
| .getSimpleName() | |
| + "\n"; | |
| } | |
| @Override | |
| protected void skipped(AssumptionViolatedException e, Description description) { | |
| watchedLog += description.getDisplayName() + " " + e.getClass() | |
| .getSimpleName() | |
| + "\n"; | |
| } | |
| @Override | |
| protected void starting(Description description) { | |
| super.starting(description); | |
| } | |
| @Override | |
| protected void finished(Description description) { | |
| super.finished(description); | |
| } | |
| }; | |
| @Test | |
| public void fails() { | |
| fail(); | |
| } | |
| @Test | |
| public void succeeds() { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment