From 3d2fc1cd212555c1ff5494c8d1893dc72c0b5492 Mon Sep 17 00:00:00 2001 From: l-1sqared <30831153+l-1squared@users.noreply.github.com> Date: Wed, 2 Feb 2022 06:51:43 +0100 Subject: [PATCH] Add fluent interface to test stages Signed-off-by: l-1sqared <30831153+l-1squared@users.noreply.github.com> --- .../main/java/com/tngtech/jgiven/tests/GivenTestStage.java | 6 ++++-- .../main/java/com/tngtech/jgiven/tests/WhenTestStage.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/GivenTestStage.java b/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/GivenTestStage.java index b180fe75e52..198ee9d1bf6 100644 --- a/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/GivenTestStage.java +++ b/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/GivenTestStage.java @@ -7,13 +7,15 @@ public GivenTestStage an_exception_is_thrown() { throw new RuntimeException("Some Exception"); } - public void nothing() { + public GivenTestStage nothing() { + return this; } - public void a_failed_step(boolean fail) { + public GivenTestStage a_failed_step(boolean fail) { if (fail) { throw new IllegalArgumentException(); } + return this; } diff --git a/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/WhenTestStage.java b/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/WhenTestStage.java index 24f4810931a..8a46fe0adbe 100644 --- a/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/WhenTestStage.java +++ b/jgiven-tests/src/main/java/com/tngtech/jgiven/tests/WhenTestStage.java @@ -8,7 +8,7 @@ public WhenTestStage something_happens() { return self(); } - public void a_step_fails() { + public WhenTestStage a_step_fails() { throw new AssertionError( "assertion failed in test step" ); }