Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into renovate/major-messag…
Browse files Browse the repository at this point in the history
…es-and-dependants
  • Loading branch information
mpkorstanje committed Feb 2, 2025
2 parents d6c7ecb + 0598529 commit c15e0bf
Show file tree
Hide file tree
Showing 20 changed files with 296 additions and 94 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- [Core] Include root cause when using DataTable.asList and friends ([#2949](https://github.com/cucumber/cucumber-jvm/pull/2949) M.P. Korstanje)
- [Core] Indent stacktrace in pretty formatter ([#2970](https://github.com/cucumber/cucumber-jvm/pull/2970) M.P. Korstanje)
- [JUnit Platform Engine] Set Engine-Version-cucumber attribute ([#2963](https://github.com/cucumber/cucumber-jvm/pull/2963) M.P. Korstanje)

### Changed
- [Archetype] Replace JUnit Jupiter with AssertJ ([#2969](https://github.com/cucumber/cucumber-jvm/pull/2969) M.P. Korstanje)
- [JUnit Platform Engine] Use JUnit Platform 1.11.3 (JUnit Jupiter 5.11.3)

### Added
Expand Down
2 changes: 1 addition & 1 deletion cucumber-archetype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ This is a Maven Archetype for setting up an empty Cucumber project. Used by the
mvn archetype:generate \
-DarchetypeGroupId=io.cucumber \
-DarchetypeArtifactId=cucumber-archetype \
-DarchetypeVersion=${cucumber.version} \
-DarchetypeVersion=${cucumber.version}
```
11 changes: 11 additions & 0 deletions cucumber-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<properties>
<junit-jupiter.version>5.11.4</junit-jupiter.version>
<assertj.version>3.25.3</assertj.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
</properties>
Expand All @@ -39,6 +40,16 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Not used by this module. But ensures the assertj.version
in the archetype template is also automatically updated by renovate
bot. -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-bom</artifactId>
<version>${assertj.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-bom</artifactId>
<version>${assertj.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -52,8 +59,8 @@
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.cucumber.java.en.*;

import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

public class StepDefinitions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-bom</artifactId>
<version>${assertj.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -52,8 +59,8 @@
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.cucumber.java.en.*;

import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

public class StepDefinitions {

Expand Down
6 changes: 3 additions & 3 deletions cucumber-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<ci-environment.version>10.0.1</ci-environment.version>
<cucumber-expressions.version>18.0.1</cucumber-expressions.version>
<gherkin.version>31.0.0</gherkin.version>
<html-formatter.version>21.7.0</html-formatter.version>
<junit-xml-formatter.version>0.5.0</junit-xml-formatter.version>
<html-formatter.version>21.8.0</html-formatter.version>
<junit-xml-formatter.version>0.7.1</junit-xml-formatter.version>
<messages.version>27.1.0</messages.version>
<query.version>12.2.0</query.version>
<query.version>13.1.0</query.version>
<tag-expressions.version>6.1.2</tag-expressions.version>
<testng-xml-formatter.version>0.2.0</testng-xml-formatter.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
public final class PrettyFormatter implements ConcurrentEventListener, ColorAware {

private static final String SCENARIO_INDENT = "";
private static final String STEP_INDENT = " ";
private static final String STEP_SCENARIO_INDENT = " ";
private static final String STEP_INDENT = SCENARIO_INDENT + " ";
private static final String STEP_SCENARIO_INDENT = STEP_INDENT + " ";
private static final String STACK_TRACE_INDENT = STEP_SCENARIO_INDENT + " ";

private final Map<UUID, Integer> commentStartIndex = new HashMap<>();

Expand Down Expand Up @@ -120,7 +121,7 @@ private void preCalculateLocationIndent(TestCaseStarted event) {
private void printTags(TestCaseStarted event) {
List<String> tags = event.getTestCase().getTags();
if (!tags.isEmpty()) {
out.println(PrettyFormatter.SCENARIO_INDENT + String.join(" ", tags));
out.println(SCENARIO_INDENT + String.join(" ", tags));
}
}

Expand Down Expand Up @@ -187,21 +188,23 @@ private String formatLocationComment(

private void printError(TestStepFinished event) {
Result result = event.getResult();
printError(result);
printError(STACK_TRACE_INDENT, result);
}

private void printError(TestRunFinished event) {
Result result = event.getResult();
printError(result);
printError(SCENARIO_INDENT, result);
}

private void printError(Result result) {
private void printError(String prefix, Result result) {
Throwable error = result.getError();
if (error != null) {
String name = result.getStatus().name().toLowerCase(ROOT);
Format format = formats.get(name);
String text = printStackTrace(error);
out.println(" " + format.text(text));
// TODO: Java 12+ use String.indent
String indented = text.replaceAll("(\r\n|\r|\n)", "$1" + prefix).trim();
out.println(prefix + format.text(indented));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.regex.Pattern;

import static io.cucumber.core.options.Constants.FILTER_TAGS_PROPERTY_NAME;
import static io.cucumber.core.plugin.IsEqualCompressingLineSeparators.equalCompressingLineSeparators;
import static io.cucumber.core.resource.ClasspathSupport.rootPackageUri;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyMap;
Expand All @@ -50,7 +51,6 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalToCompressingWhiteSpace;
import static org.hamcrest.collection.IsEmptyCollection.empty;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
Expand Down Expand Up @@ -411,7 +411,7 @@ void ensure_less_than_1_thread_is_not_allowed() {
parser
.parse("--threads", "0")
.build();
assertThat(output(), equalToCompressingWhiteSpace("--threads must be > 0"));
assertThat(output(), equalCompressingLineSeparators("--threads must be > 0"));
assertThat(parser.exitStatus(), is(Optional.of((byte) 0x1)));
}

Expand Down Expand Up @@ -518,7 +518,7 @@ void ensure_less_than_1_count_is_not_allowed() {
parser
.parse("--count", "0")
.build();
assertThat(output(), equalToCompressingWhiteSpace("--count must be > 0"));
assertThat(output(), equalCompressingLineSeparators("--count must be > 0"));
assertThat(parser.exitStatus(), is(Optional.of((byte) 0x1)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import java.util.Locale;
import java.util.UUID;

import static io.cucumber.core.plugin.IsEqualCompressingLineSeparators.equalCompressingLineSeparators;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.time.Instant.ofEpochSecond;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.text.IsEqualCompressingWhiteSpace.equalToCompressingWhiteSpace;

class DefaultSummaryPrinterTest {

Expand Down Expand Up @@ -56,7 +56,7 @@ void does_not_print_duplicate_snippets() {

bus.send(new TestRunFinished(bus.getInstant(), new Result(Status.PASSED, Duration.ZERO, null)));

assertThat(new String(out.toByteArray(), UTF_8), equalToCompressingWhiteSpace("" +
assertThat(new String(out.toByteArray(), UTF_8), equalCompressingLineSeparators("" +
"\n" +
"0 Scenarios\n" +
"0 Steps\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.cucumber.core.plugin;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import java.util.Objects;

public class IsEqualCompressingLineSeparators extends TypeSafeMatcher<String> {

private final String expected;

public IsEqualCompressingLineSeparators(String expected) {
Objects.requireNonNull(expected);
this.expected = expected;
}

public String getExpected() {
return expected;
}

@Override
public boolean matchesSafely(String actual) {
return compressNewLines(expected).equals(compressNewLines(actual));
}

@Override
public void describeMismatchSafely(String item, Description mismatchDescription) {
mismatchDescription.appendText("was ").appendValue(item);
}

@Override
public void describeTo(Description description) {
description.appendText("a string equal to ")
.appendValue(expected)
.appendText(" compressing newlines");
}

public String compressNewLines(String actual) {
return actual.replaceAll("[\r\n]+", "\n").trim();
}

public static Matcher<String> equalCompressingLineSeparators(String expectedString) {
return new IsEqualCompressingLineSeparators(expectedString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ void writes_report_xml() {

assertThat(bytes, bytes(equalTo("" +
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<testsuite name=\"Cucumber\" time=\"5\" tests=\"0\" skipped=\"0\" failures=\"0\" errors=\"0\">\n" +
"<testsuite name=\"Cucumber\" time=\"5\" tests=\"0\" skipped=\"0\" failures=\"0\" errors=\"0\" timestamp=\"1970-01-01T00:00:10Z\">\n"
+
"</testsuite>\n")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void should_format_scenario_with_a_failed_step() throws JSONException {
.withEventBus(new TimeServiceEventBus(timeService, UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("there are bananas", "StepDefs.there_are_bananas()",
new StubException())))
new StubException("the stack trace"))))
.build()
.run();

Expand Down Expand Up @@ -1485,5 +1485,4 @@ void should_handle_several_features() throws JSONException {
"]";
assertJsonEquals(expected, out);
}

}
Loading

0 comments on commit c15e0bf

Please sign in to comment.