Skip to content
Merged
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 @@ -15,6 +15,7 @@
import io.cucumber.plugin.event.EventPublisher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.hamcrest.core.Is;
import org.junit.jupiter.api.Test;
Expand All @@ -38,7 +39,6 @@

import static io.cucumber.core.options.Constants.FILTER_TAGS_PROPERTY_NAME;
import static io.cucumber.core.resource.ClasspathSupport.rootPackageUri;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singleton;
Expand All @@ -49,6 +49,7 @@
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.IsIterableContainingInOrder.contains;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.core.IsEqual.equalTo;
Expand Down Expand Up @@ -77,12 +78,12 @@ void testParseWithObjectFactoryArgument() {
@Test
void has_version_from_properties_file() {
parser.parse("--version");
assertThat(output(), matchesPattern("\\d+\\.\\d+\\.\\d+(-RC\\d+)?(-SNAPSHOT)?\n"));
assertThat(output(), matchesPattern("\\d+\\.\\d+\\.\\d+(-RC\\d+)?(-SNAPSHOT)?\r?\n"));
assertThat(parser.exitStatus(), is(Optional.of((byte) 0x0)));
}

private String output() {
return new String(out.toByteArray(), UTF_8);
return new String(out.toByteArray());
}

@Test
Expand Down Expand Up @@ -361,7 +362,7 @@ void ensure_less_than_1_thread_is_not_allowed() {
parser
.parse("--threads", "0")
.build();
assertThat(output(), is("--threads must be > 0\n"));
assertThat(output(), equalToCompressingWhiteSpace("--threads must be > 0"));
assertThat(parser.exitStatus(), is(Optional.of((byte) 0x1)));
}

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

Expand Down
8 changes: 5 additions & 3 deletions core/src/test/java/io/cucumber/core/plugin/BannerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import static io.cucumber.core.plugin.BytesEqualTo.isBytesEqualTo;
import static java.util.Arrays.asList;
Expand All @@ -13,9 +15,9 @@
class BannerTest {

@Test
void printsAnsiBanner() {
void printsAnsiBanner() throws UnsupportedEncodingException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Banner banner = new Banner(new PrintStream(bytes), false);
Banner banner = new Banner(new PrintStream(bytes, false, StandardCharsets.UTF_8.name()), false);

banner.print(asList(
new Banner.Line("Bla"),
Expand All @@ -37,7 +39,7 @@ void printsAnsiBanner() {
@Test
void printsMonochromeBanner() throws Exception {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Banner banner = new Banner(new PrintStream(bytes), true);
Banner banner = new Banner(new PrintStream(bytes, false, StandardCharsets.UTF_8.name()), true);

banner.print(asList(
new Banner.Line("Bla"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import static io.cucumber.core.plugin.BytesEqualTo.isBytesEqualTo;
import static org.hamcrest.MatcherAssert.assertThat;

class NoPublishFormatterTest {
@Test
public void should_print_banner() {
public void should_print_banner() throws UnsupportedEncodingException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintStream out = new PrintStream(bytes);
PrintStream out = new PrintStream(bytes, false, StandardCharsets.UTF_8.name());
NoPublishFormatter noPublishFormatter = new NoPublishFormatter(out);
noPublishFormatter.setMonochrome(true);
noPublishFormatter.printBanner();
Expand Down
10 changes: 6 additions & 4 deletions core/src/test/java/io/cucumber/core/plugin/UrlReporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import static io.cucumber.core.plugin.BytesEqualTo.isBytesEqualTo;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -22,17 +24,17 @@ class UrlReporterTest {
"\u001B[32m\u001B[1m└──────────────────────────────────────────────────────────────────────────┘\u001B[0m\n";

@Test
void printsTheCorrespondingReportsCucumberIoUrl() {
void printsTheCorrespondingReportsCucumberIoUrl() throws UnsupportedEncodingException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
UrlReporter urlReporter = new UrlReporter(new PrintStream(bytes));
UrlReporter urlReporter = new UrlReporter(new PrintStream(bytes, false, StandardCharsets.UTF_8.name()));
urlReporter.report(message);
assertThat(bytes, isBytesEqualTo(message));
}

@Test
void printsTheCorrespondingReportsCucumberIoUrlInMonoChrome() {
void printsTheCorrespondingReportsCucumberIoUrlInMonoChrome() throws UnsupportedEncodingException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
UrlReporter urlReporter = new UrlReporter(new PrintStream(bytes));
UrlReporter urlReporter = new UrlReporter(new PrintStream(bytes, false, StandardCharsets.UTF_8.name()));
urlReporter.setMonochrome(true);

urlReporter.report(message);
Expand Down