From ea411a0afbc079fc179f054b79acbc4367028025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sat, 28 Jul 2018 11:01:57 +0200 Subject: [PATCH] Add test for varargs formatting #351 --- .../java/com/tngtech/jgiven/GivenTestStep.java | 4 ++++ .../report/text/PlainTextReporterTest.java | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jgiven-core/src/test/java/com/tngtech/jgiven/GivenTestStep.java b/jgiven-core/src/test/java/com/tngtech/jgiven/GivenTestStep.java index 1292f39550..f9821091df 100644 --- a/jgiven-core/src/test/java/com/tngtech/jgiven/GivenTestStep.java +++ b/jgiven-core/src/test/java/com/tngtech/jgiven/GivenTestStep.java @@ -113,6 +113,10 @@ public GivenTestStep a_step_with_an_As_annotation_and_a_custom_provider() { return self(); } + public GivenTestStep varargs_as_parameters_$( String... params ) { + return self(); + } + public GivenTestStep ALLUPPERCASE() { return self(); } diff --git a/jgiven-core/src/test/java/com/tngtech/jgiven/report/text/PlainTextReporterTest.java b/jgiven-core/src/test/java/com/tngtech/jgiven/report/text/PlainTextReporterTest.java index ccf83eb78b..d8c121ed62 100644 --- a/jgiven-core/src/test/java/com/tngtech/jgiven/report/text/PlainTextReporterTest.java +++ b/jgiven-core/src/test/java/com/tngtech/jgiven/report/text/PlainTextReporterTest.java @@ -18,11 +18,7 @@ import com.tngtech.jgiven.ScenarioTestBaseForTesting; import com.tngtech.jgiven.ThenTestStep; import com.tngtech.jgiven.WhenTestStep; -import com.tngtech.jgiven.annotation.Format; -import com.tngtech.jgiven.annotation.Formatf; -import com.tngtech.jgiven.annotation.NamedFormat; -import com.tngtech.jgiven.annotation.POJOFormat; -import com.tngtech.jgiven.annotation.Quoted; +import com.tngtech.jgiven.annotation.*; import com.tngtech.jgiven.annotation.POJOFormat.BracketsEnum; import com.tngtech.jgiven.exception.JGivenWrongUsageException; import com.tngtech.jgiven.format.BooleanFormatter; @@ -366,6 +362,16 @@ public void step_comments_are_printed() throws UnsupportedEncodingException { assertThat( string ).contains( "something [This is a comment.]" ); } + @Test + public void varargs_formatting() throws UnsupportedEncodingException { + getScenario().startScenario( "varargs" ); + + given().varargs_as_parameters_$( "a", "b", "c" ); + + String string = PlainTextReporter.toString( getScenario().getScenarioModel() ); + assertThat( string ).contains( "Given varargs as parameters a, b, c" ); + } + @Test public void pojo_format_is_working() throws Throwable { getScenario().startScenario( "test" );