Skip to content

Commit

Permalink
- t inline to improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed May 6, 2024
1 parent ddd5b4b commit 17ccb93
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void testSemiAutomatic()
***** DELETE ME TO APPROVE *****
""";
Options options = new Options().inline("", InlineOptions.semiAutomatic());
Mutable<String> result = hijackInlineReporter(options, AutoApproveReporter.class);
Mutable<String> result = hijackInlineReporter(options);
Action1<Throwable> assertion = e -> assertEquals(expected, result.get());
assertApprovalFailure("hello Lars", options, assertion);
}
Expand All @@ -151,9 +151,8 @@ void testAutomatic()
hello Oskar
""";
Options options = new Options().inline("", InlineOptions.automatic());
Mutable<String> result = hijackInlineReporter(options, AutoApproveReporter.class);
Action1<Throwable> assertion = e -> assertEquals(expected, result.get());
assertApprovalFailure("hello Oskar", options, assertion);
assertApprovalFailure("hello Oskar", options,
e -> assertEquals(expected, hijackInlineReporter(options).get()));
}
private static void assertApprovalFailure(String actual, Options options, Action1<Throwable> azzert)
{
Expand All @@ -169,10 +168,10 @@ private static void assertApprovalFailure(String actual, Options options, Action
}
assertTrue(failed, "Approval should have failed");
}
private static Mutable<String> hijackInlineReporter(Options options, Class<AutoApproveReporter> reporterClass)
private static Mutable<String> hijackInlineReporter(Options options)
{
InlineJavaReporter reporter = (InlineJavaReporter) options.getReporter();
assertEquals(reporter.reporter.getClass(), reporterClass);
assertEquals(reporter.reporter.getClass(), AutoApproveReporter.class);
reporter.reporter = new QuietReporter();
Mutable<String> result = new Mutable<>("");
reporter.createNewReceivedFileText = (s, a, m) -> result.set(a);
Expand Down

0 comments on commit 17ccb93

Please sign in to comment.