fix missing status

This commit is contained in:
Michael Hoennig 2024-10-29 17:43:46 +01:00
parent 3fd2b6f693
commit 77cf97ded9
2 changed files with 9 additions and 9 deletions

View File

@ -16,9 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestReport {
private final Map<String, ?> aliases;
private final StringBuilder debugLog = new StringBuilder(); // records everything for debugging purposes
private final StringBuilder markdownLog = new StringBuilder(); // records everything for debugging purposes
private PrintWriter markdownFile;
private PrintWriter markdownReport;
private int silent; // do not print anything to test-report if >0
public TestReport(final Map<String, ?> aliases) {
@ -29,22 +29,22 @@ public class TestReport {
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
markdownFile = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
markdownReport = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
print("## Scenario: " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
}
@SneakyThrows
public void print(final String output) {
final var outputWithCommentsForUuids = appendUUIDKey(output.replace("+", "\\+"));
final var outputWithCommentsForUuids = appendUUIDKey(output);
// for tests executed due to @Requires/@Produces there is no markdownFile yet
if (silent == 0) {
markdownFile.print(outputWithCommentsForUuids);
markdownReport.print(outputWithCommentsForUuids);
}
// but the debugLog should contain all output, even if silent
debugLog.append(outputWithCommentsForUuids);
markdownLog.append(outputWithCommentsForUuids);
}
public void printLine(final String output) {
@ -56,7 +56,7 @@ public class TestReport {
}
public void close() {
markdownFile.close();
markdownReport.close();
}
private String appendUUIDKey(String multilineText) {

View File

@ -281,8 +281,8 @@ public abstract class UseCase<T extends UseCase<?>> {
testReport.printLine(httpMethod.name() + " " + uri);
testReport.printLine((requestBody != null ? requestBody.trim() : ""));
// the response + "=> status: " + status + " " +
testReport.printLine(locationUuid != null ? locationUuid.toString() : "");
// the response
testReport.printLine("=> status: " + status + " " + (locationUuid != null ? locationUuid : ""));
if (httpMethod == HttpMethod.GET || status.isError()) {
final var jsonNode = objectMapper.readTree(response.body());
final var prettyJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);