Skip to content

Show actual events in test runner #2631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Result createResult(ValidatedResult<Model> validatedResult) {
.filter(event -> !isModelDeprecationEvent(event))
.collect(Collectors.toList());

return new SmithyTestCase.Result(getModelLocation(), unmatchedEvents, extraEvents);
return new SmithyTestCase.Result(getModelLocation(), unmatchedEvents, extraEvents, actualEvents);
}

private static boolean compareEvents(ValidationEvent expected, ValidationEvent actual) {
Expand Down Expand Up @@ -197,15 +197,18 @@ public static final class Result {
private final String modelLocation;
private final Collection<ValidationEvent> unmatchedEvents;
private final Collection<ValidationEvent> extraEvents;
private final Collection<ValidationEvent> actualEvents;

Result(
String modelLocation,
Collection<ValidationEvent> unmatchedEvents,
Collection<ValidationEvent> extraEvents
Collection<ValidationEvent> extraEvents,
Collection<ValidationEvent> actualEvents
) {
this.modelLocation = modelLocation;
this.unmatchedEvents = Collections.unmodifiableCollection(new TreeSet<>(unmatchedEvents));
this.extraEvents = Collections.unmodifiableCollection(new TreeSet<>(extraEvents));
this.actualEvents = Collections.unmodifiableCollection(new TreeSet<>(actualEvents));
}

@Override
Expand Down Expand Up @@ -236,6 +239,13 @@ public String toString() {
builder.append('\n');
}

builder.append("\nActual events\n"
+ "-------------\n");
for (ValidationEvent event : actualEvents) {
builder.append(event.toString().replace("\n", "\\n")).append("\n");
}
builder.append('\n');

return builder.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public void newlinesAreBetweenEventsWhenFormatting() {
SmithyTestCase.Result result = new SmithyTestCase.Result(
"/foo/bar.json",
ListUtils.of(e1, e2),
ListUtils.of(e1, e2));
ListUtils.of(e1, e2),
ListUtils.of());

assertThat(result.toString(),
equalTo("=======================\n"
Expand All @@ -136,6 +137,11 @@ public void newlinesAreBetweenEventsWhenFormatting() {
+ "Encountered unexpected events\n"
+ "-----------------------------\n"
+ "[DANGER] foo.baz#Bar: a | FooBar N/A:0:0\n"
+ "[DANGER] foo.baz#Bar: b | FooBar N/A:0:0\n\n"));
+ "[DANGER] foo.baz#Bar: b | FooBar N/A:0:0\n"
+ "\n"
+ "\n"
+ "Actual events\n"
+ "-------------\n"
+ "\n"));
}
}
Loading