From ab4d5cc13d6b8dd66ef04c84eff2b0691ccf2a47 Mon Sep 17 00:00:00 2001 From: Nil MALHOMME <31489080+nil-malh@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:37:59 +0200 Subject: [PATCH] Revert "Adds the support of multiple reports formats (#65)" This reverts commit 88f1dc65bd919b38750ed0bde76a10c7ae9055d0. --- .../ktestify/config/FrameworkConfig.java | 23 +----------- src/main/resources/application.conf.template | 3 +- src/main/resources/reference.conf | 4 +- .../ktestify/config/FrameworkConfigTest.java | 37 +++++-------------- 4 files changed, 15 insertions(+), 52 deletions(-) diff --git a/src/main/java/io/github/ktestify/config/FrameworkConfig.java b/src/main/java/io/github/ktestify/config/FrameworkConfig.java index d68d728..d16a9c7 100644 --- a/src/main/java/io/github/ktestify/config/FrameworkConfig.java +++ b/src/main/java/io/github/ktestify/config/FrameworkConfig.java @@ -16,11 +16,9 @@ package io.github.ktestify.config; import com.typesafe.config.Config; -import com.typesafe.config.ConfigValueType; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; -import java.util.List; import java.util.Optional; import lombok.Getter; @@ -55,7 +53,7 @@ public final class FrameworkConfig { // Reporting private final boolean enableReporting; - private final List reportFormats; + private final String reportFormat; private final String reportOutputDirectory; FrameworkConfig(Config config) { @@ -83,27 +81,10 @@ public final class FrameworkConfig { // Reporting Config reportConfig = config.getConfig("reporting"); this.enableReporting = reportConfig.getBoolean("enabled"); - this.reportFormats = readReportFormats(reportConfig); + this.reportFormat = reportConfig.getString("format"); this.reportOutputDirectory = reportConfig.getString("output"); } - /** - * Reads the configured report formats. - * - *

{@code ktestify.framework.reporting.format} accepts either a single string ({@code format = "html"}) or an - * array of strings ({@code format = ["html", "json"]}). A single string is wrapped into a one-element list so - * existing configurations keep working. - * - * @param reportConfig the reporting config section - * @return the configured report formats, never null - */ - private static List readReportFormats(Config reportConfig) { - if (reportConfig.getValue("format").valueType() == ConfigValueType.STRING) { - return List.of(reportConfig.getString("format")); - } - return List.copyOf(reportConfig.getStringList("format")); - } - private Optional getOptionalString(Config config, String path) { if (config.hasPath(path) && !config.getIsNull(path)) { String value = config.getString(path); diff --git a/src/main/resources/application.conf.template b/src/main/resources/application.conf.template index 8417cf9..0e406ee 100644 --- a/src/main/resources/application.conf.template +++ b/src/main/resources/application.conf.template @@ -89,8 +89,7 @@ ktestify { # Reporting settings reporting { enabled = true - # One or more report formats: html, json, pretty - format = ["html"] + format = "html" output = "target/test-output" } } diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 747074f..19835b3 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -160,8 +160,8 @@ ktestify { # Reporting settings reporting { enabled = true - # Report formats: html, json, pretty. Single value or array, e.g. ["html", "json"] - format = ["html"] + # Format: html, json, cucumber + format = "html" # Directory for test output/reports output = "src/target/reports/report.html" output = ${?KTESTIFY_OUTPUT_DIR} diff --git a/src/test/java/io/github/ktestify/config/FrameworkConfigTest.java b/src/test/java/io/github/ktestify/config/FrameworkConfigTest.java index 0504a38..46cf0d6 100644 --- a/src/test/java/io/github/ktestify/config/FrameworkConfigTest.java +++ b/src/test/java/io/github/ktestify/config/FrameworkConfigTest.java @@ -20,8 +20,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; -import java.util.List; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; /** * Comprehensive unit tests for FrameworkConfig. Tests all getters, timeout conversions, path resolution, and edge @@ -339,9 +342,9 @@ void shouldGetEnableReporting() { } @Test - @DisplayName("Should get default report formats") - void shouldGetDefaultReportFormats() { - assertEquals(List.of("html"), frameworkConfig.getReportFormats()); + @DisplayName("Should get report format") + void shouldGetReportFormat() { + assertEquals("html", frameworkConfig.getReportFormat()); } @Test @@ -357,36 +360,16 @@ void shouldHandleDisabledReporting() { @Test @DisplayName("Should handle different report formats") void shouldHandleDifferentReportFormats() { - String[] formats = {"html", "json", "pretty"}; + String[] formats = {"html", "json", "cucumber"}; for (String format : formats) { KtestifyConfig config = ConfigBuilder.create() .set("ktestify.framework.reporting.format", format) .build(); - assertEquals(List.of(format), config.getFramework().getReportFormats()); + assertEquals(format, config.getFramework().getReportFormat()); } } - - @Test - @DisplayName("Should accept an array of report formats") - void shouldAcceptArrayOfReportFormats() { - KtestifyConfig config = ConfigBuilder.create() - .set("ktestify.framework.reporting.format", List.of("html", "json")) - .build(); - - assertEquals(List.of("html", "json"), config.getFramework().getReportFormats()); - } - - @Test - @DisplayName("Should handle an empty array of report formats") - void shouldHandleEmptyArrayOfReportFormats() { - KtestifyConfig config = ConfigBuilder.create() - .set("ktestify.framework.reporting.format", List.of()) - .build(); - - assertTrue(config.getFramework().getReportFormats().isEmpty()); - } } // ==========================================