From c9dcbfc8396bba6b8aa6cdecfcd1e26efd99ccfa Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Thu, 22 Jun 2017 16:40:06 +0200 Subject: [PATCH 01/12] Refactor to delete the then step creation. --- .../src/main/java/testasyouthink/TestAsYouThink.java | 12 ++++-------- .../main/java/testasyouthink/ThenStepFactory.java | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java b/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java index 67ed3a9..55b0963 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java @@ -31,6 +31,8 @@ public class TestAsYouThink { + private static ThenStepFactory thenStepFactory = ThenStepFactory.INSTANCE; + public static <$SystemUnderTest> Given<$SystemUnderTest> givenSut($SystemUnderTest systemUnderTest) { return new GivenWhenSteps<>(systemUnderTest); } @@ -44,19 +46,13 @@ public class TestAsYouThink { } public static ThenWithoutResultStep when(Runnable whenStep) { - Preparation nothingToPrepare = new Preparation<>(null); CheckedConsumer whenStepAsVoidConsumer = Void -> whenStep.run(); - Event event = new Event<>(null, whenStepAsVoidConsumer); - GivenWhenContext context = new GivenWhenContext<>(nothingToPrepare, event); - return new ThenWithoutResultStep<>(context); + return thenStepFactory.createThenStep(whenStepAsVoidConsumer); } public static <$Result> Then when(Supplier<$Result> whenStep) { - Preparation nothingToPrepare = new Preparation<>(null); CheckedFunction whenStepAsFunction = Void -> whenStep.get(); - Event event = new Event<>(null, whenStepAsFunction); - GivenWhenContext context = new GivenWhenContext<>(nothingToPrepare, event); - return new ThenStep<>(context); + return thenStepFactory.createThenStep(whenStepAsFunction); } public static <$SystemUnderTest, $Result> CheckedFunction<$SystemUnderTest, $Result> withReturn( diff --git a/test-as-you-think-core/src/main/java/testasyouthink/ThenStepFactory.java b/test-as-you-think-core/src/main/java/testasyouthink/ThenStepFactory.java index 983db89..a11efd6 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/ThenStepFactory.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/ThenStepFactory.java @@ -42,4 +42,14 @@ enum ThenStepFactory { GivenWhenContext<$SystemUnderTest, Void> context = new GivenWhenContext<>(preparation, event); return new ThenWithoutResultStep<>(context); } + + <$Result> ThenStep createThenStep(CheckedFunction whenStep) { + Preparation nothingToPrepare = new Preparation<>(null); + return createThenStep(nothingToPrepare, whenStep); + } + + ThenWithoutResultStep createThenStep(CheckedConsumer whenStep) { + Preparation nothingToPrepare = new Preparation<>(null); + return createThenStep(nothingToPrepare, whenStep); + } } From 2deb853641ac27e8d88e412f263d4a937042c3fa Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Thu, 22 Jun 2017 16:56:09 +0200 Subject: [PATCH 02/12] Refactor to delegate the lambda transformations. --- .../src/main/java/testasyouthink/TestAsYouThink.java | 9 ++++----- .../src/main/java/testasyouthink/function/Functions.java | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java b/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java index 55b0963..f84e5f5 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/TestAsYouThink.java @@ -24,13 +24,14 @@ import testasyouthink.GivenWhenThenDsl.PreparationStage.Given; import testasyouthink.GivenWhenThenDsl.VerificationStage.Then; -import testasyouthink.function.CheckedConsumer; import testasyouthink.function.CheckedFunction; +import testasyouthink.function.Functions; import java.util.function.Supplier; public class TestAsYouThink { + private static Functions functions = Functions.INSTANCE; private static ThenStepFactory thenStepFactory = ThenStepFactory.INSTANCE; public static <$SystemUnderTest> Given<$SystemUnderTest> givenSut($SystemUnderTest systemUnderTest) { @@ -46,13 +47,11 @@ public class TestAsYouThink { } public static ThenWithoutResultStep when(Runnable whenStep) { - CheckedConsumer whenStepAsVoidConsumer = Void -> whenStep.run(); - return thenStepFactory.createThenStep(whenStepAsVoidConsumer); + return thenStepFactory.createThenStep(functions.toCheckedConsumer(whenStep)); } public static <$Result> Then when(Supplier<$Result> whenStep) { - CheckedFunction whenStepAsFunction = Void -> whenStep.get(); - return thenStepFactory.createThenStep(whenStepAsFunction); + return thenStepFactory.createThenStep(functions.toCheckedFunction(whenStep)); } public static <$SystemUnderTest, $Result> CheckedFunction<$SystemUnderTest, $Result> withReturn( diff --git a/test-as-you-think-core/src/main/java/testasyouthink/function/Functions.java b/test-as-you-think-core/src/main/java/testasyouthink/function/Functions.java index d87441b..d0ad87a 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/function/Functions.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/function/Functions.java @@ -39,6 +39,10 @@ public Consumer toConsumer(Runnable runnable) { return toBeConsumed -> runnable.run(); } + public CheckedConsumer toCheckedConsumer(Runnable runnable) { + return toBeConsumed -> runnable.run(); + } + public CheckedFunction toFunction(CheckedConsumer checkedConsumer) { return toBeConsumed -> { checkedConsumer.accept(toBeConsumed); @@ -46,6 +50,10 @@ public CheckedFunction toFunction(CheckedConsumer checkedConsume }; } + public CheckedFunction toCheckedFunction(Supplier supplier) { + return Void -> supplier.get(); + } + public CheckedFunction toFunctionWithThrowableAsResult(CheckedConsumer checkedConsumer) { return toBeConsumed -> { Throwable result = null; From 65ee04e19ee8a4ebef9e7209da0a6c3d1d802df2 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 16:35:27 +0200 Subject: [PATCH 03/12] Tell Travis CI what to build. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dff5f3a --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: java From 15a03754534c8aa76a57a69be4db553f12d9e437 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 16:47:41 +0200 Subject: [PATCH 04/12] Install Maven 3.5.0 as a additional dependency before Travis builds the project. - By default, Travis uses Maven 3.2.5 in its CI environment reference. Source: https://docs.travis-ci.com/user/ci-environment/ - Also update the Maven version of the project. --- .travis.yml | 5 +++++ pom.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dff5f3a..844146f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,6 @@ language: java +before_install: + - wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip + - unzip -qq apache-maven-3.5.0-bin.zip + - export M2_HOME=${PWD}/apache-maven-3.5.0 + - export PATH=${M2_HOME}/bin:${PATH} diff --git a/pom.xml b/pom.xml index 09e642c..fcc902b 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.8 ${java.version} ${java.version} - 3.3.9 + 3.5.0 From 11dd7529ff9cadbe3347ff6410f13b0220550d17 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 17:17:48 +0200 Subject: [PATCH 05/12] Replace the Oracle JDK 7 provided by Travis by default with the Oracle JDK 8. Source: https://docs.travis-ci.com/user/languages/java/ --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 844146f..b26e015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,5 @@ before_install: - unzip -qq apache-maven-3.5.0-bin.zip - export M2_HOME=${PWD}/apache-maven-3.5.0 - export PATH=${M2_HOME}/bin:${PATH} +jdk: + - oraclejdk8 From e9a02f9c1e4be690571cb4466d38666bb2c6164a Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 18:01:21 +0200 Subject: [PATCH 06/12] Cache dependencies to speed up the build process. - Cache Maven and its repository folder as dependencies. https://docs.travis-ci.com/user/caching - Use environment variables as defined here: https://docs.travis-ci.com/user/environment-variables/ --- .travis.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b26e015..c04ac0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,25 @@ language: java +cache: + directories: + - ${HOME}/.m2 + - ${TRAVIS_BUILD_DIR}/dependencies +sudo: required before_install: - - wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip - - unzip -qq apache-maven-3.5.0-bin.zip - - export M2_HOME=${PWD}/apache-maven-3.5.0 + - echo ${TRAVIS_BUILD_DIR} + - echo ${PWD} + - echo "====== DEPENDENCIES - Start ======" + - sudo apt-get install tree + - export DEP_DIR=${TRAVIS_BUILD_DIR}/dependencies + - tree ${DEP_DIR} + - echo "====== MAVEN - Start ======" + - export MVN_VERSION=3.5.0 + - export M2_HOME=${DEP_DIR}/maven/apache-maven-${MVN_VERSION} - export PATH=${M2_HOME}/bin:${PATH} + - test -d ${M2_HOME} || (wget https://archive.apache.org/dist/maven/maven-3/${MVN_VERSION}/binaries/apache-maven-${MVN_VERSION}-bin.zip && unzip -qq apache-maven-${MVN_VERSION}-bin.zip -d ${DEP_DIR}/maven) + - mvn --version + - mvn help:evaluate -Dexpression=settings.localRepository | grep -E '^([/a-zA-Z0-9_. \-]+)$' + - echo "====== MAVEN - End ======" + - tree ${DEP_DIR} + - echo "====== DEPENDENCIES - End ======" jdk: - oraclejdk8 From 045e9bed375b18c8e4091819b067ee275b317fc9 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 23:11:05 +0200 Subject: [PATCH 07/12] Replace uses of sudo with APT packages coming from Travis's container-based infrastructure. Source: https://docs.travis-ci.com/user/installing-dependencies#Installing-Packages-with-the-APT-Addon --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c04ac0f..52a562d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,14 @@ cache: directories: - ${HOME}/.m2 - ${TRAVIS_BUILD_DIR}/dependencies -sudo: required +addons: + apt: + packages: + - tree before_install: - echo ${TRAVIS_BUILD_DIR} - echo ${PWD} - echo "====== DEPENDENCIES - Start ======" - - sudo apt-get install tree - export DEP_DIR=${TRAVIS_BUILD_DIR}/dependencies - tree ${DEP_DIR} - echo "====== MAVEN - Start ======" From efe463c54136e208a6ea2eee98ac5d4b2cbcc5ba Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 15:52:48 +0200 Subject: [PATCH 08/12] Rearrange the badge presentation in the documentation. --- README.md | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8559575..da18061 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,10 @@ What you think is what you test... Not yet another testing API or framework! -Software: -[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven/apache-maven.svg)](https://search.maven.org/#artifactdetails%7Ccom.github.xapn%7Ctest-as-you-think-core%7C0.4%7C) -[![Javadocs](http://javadoc.io/badge/com.github.xapn/test-as-you-think-core.svg?color=orange)](http://javadoc.io/doc/com.github.xapn/test-as-you-think-core) -[![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) - -Counters: -[![LoC](https://tokei.rs/b1/github/xapn/test-as-you-think?category=code)](https://github.com/xapn/test-as-you-think) -[![Files](https://tokei.rs/b1/github/xapn/test-as-you-think?category=files)](https://github.com/xapn/test-as-you-think) -[![Total lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=lines)](https://github.com/xapn/test-as-you-think) -[![Comments](https://tokei.rs/b1/github/xapn/test-as-you-think?category=comments)](https://github.com/xapn/test-as-you-think) -[![Blank lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=blanks)](https://github.com/xapn/test-as-you-think) - -Social: -[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/search?q=%23TestAsYouThink) -[![Twitter Follow](https://img.shields.io/twitter/follow/espadrine.svg?style=social&label=Follow)](https://twitter.com/XEngineer) -[![GitHub stars](https://img.shields.io/github/stars/badges/shields.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) -[![GitHub watchers](https://img.shields.io/github/watchers/badges/shields.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) -[![GitHub forks](https://img.shields.io/github/forks/badges/shields.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think) +Matter | Badges +------ | ------ +Software factory | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven/apache-maven.svg)](https://search.maven.org/#artifactdetails%7Ccom.github.xapn%7Ctest-as-you-think-core%7C0.4%7C) [![Javadocs](http://javadoc.io/badge/com.github.xapn/test-as-you-think-core.svg?color=orange)](http://javadoc.io/doc/com.github.xapn/test-as-you-think-core) [![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) +Source code | [![LoC](https://tokei.rs/b1/github/xapn/test-as-you-think?category=code)](https://github.com/xapn/test-as-you-think) [![Files](https://tokei.rs/b1/github/xapn/test-as-you-think?category=files)](https://github.com/xapn/test-as-you-think) [![Total lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=lines)](https://github.com/xapn/test-as-you-think) [![Comments](https://tokei.rs/b1/github/xapn/test-as-you-think?category=comments)](https://github.com/xapn/test-as-you-think) [![Blank lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=blanks)](https://github.com/xapn/test-as-you-think) +Social | [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/search?q=%23TestAsYouThink) [![Twitter Follow](https://img.shields.io/twitter/follow/espadrine.svg?style=social&label=Follow)](https://twitter.com/XEngineer) [![GitHub stars](https://img.shields.io/github/stars/badges/shields.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) [![GitHub watchers](https://img.shields.io/github/watchers/badges/shields.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) [![GitHub forks](https://img.shields.io/github/forks/badges/shields.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think) From d8e191e86a493ce040cc97292b4690f2c0834321 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Thu, 22 Jun 2017 18:59:24 +0200 Subject: [PATCH 09/12] Add the Travis badges, one for the master branch, one for the develop one. Source: https://docs.travis-ci.com/user/status-images/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da18061..b3dd887 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ What you think is what you test... Not yet another testing API or framework! Matter | Badges ------ | ------ -Software factory | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven/apache-maven.svg)](https://search.maven.org/#artifactdetails%7Ccom.github.xapn%7Ctest-as-you-think-core%7C0.4%7C) [![Javadocs](http://javadoc.io/badge/com.github.xapn/test-as-you-think-core.svg?color=orange)](http://javadoc.io/doc/com.github.xapn/test-as-you-think-core) [![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) +Software factory | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven/apache-maven.svg)](https://search.maven.org/#artifactdetails%7Ccom.github.xapn%7Ctest-as-you-think-core%7C0.4%7C) [![Build Status for master](https://travis-ci.org/xapn/test-as-you-think.svg?branch=master)](https://travis-ci.org/xapn/test-as-you-think) [![Build Status for develop](https://travis-ci.org/xapn/test-as-you-think.svg?branch=develop)](https://travis-ci.org/xapn/test-as-you-think) [![Javadocs](http://javadoc.io/badge/com.github.xapn/test-as-you-think-core.svg?color=orange)](http://javadoc.io/doc/com.github.xapn/test-as-you-think-core) [![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) Source code | [![LoC](https://tokei.rs/b1/github/xapn/test-as-you-think?category=code)](https://github.com/xapn/test-as-you-think) [![Files](https://tokei.rs/b1/github/xapn/test-as-you-think?category=files)](https://github.com/xapn/test-as-you-think) [![Total lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=lines)](https://github.com/xapn/test-as-you-think) [![Comments](https://tokei.rs/b1/github/xapn/test-as-you-think?category=comments)](https://github.com/xapn/test-as-you-think) [![Blank lines](https://tokei.rs/b1/github/xapn/test-as-you-think?category=blanks)](https://github.com/xapn/test-as-you-think) Social | [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/search?q=%23TestAsYouThink) [![Twitter Follow](https://img.shields.io/twitter/follow/espadrine.svg?style=social&label=Follow)](https://twitter.com/XEngineer) [![GitHub stars](https://img.shields.io/github/stars/badges/shields.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) [![GitHub watchers](https://img.shields.io/github/watchers/badges/shields.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) [![GitHub forks](https://img.shields.io/github/forks/badges/shields.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think) From 92bec0f62133630332f4c0f6a2eaab66f50b8722 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Fri, 23 Jun 2017 23:49:26 +0200 Subject: [PATCH 10/12] Write the release note. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b3dd887..e4819d9 100644 --- a/README.md +++ b/README.md @@ -305,6 +305,10 @@ The advantage of TestAsYouThink is that the time limit is only applied to the te # Release Notes +## Version 0.4.1: Travis CI as a continuous integration platform + +- Build the project with [Travis CI](https://travis-ci.org). + ## Version 0.4: Time limit as an expectation - Expect that the system under test replies within a time limit. From 51974827eb5ad27256a1d6f9eb4bc87525262e35 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 13:16:45 +0200 Subject: [PATCH 11/12] Update the documentation. --- README.md | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e4819d9..eb1591f 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ givenSutClass(SystemUnderTest.class) ``` Notice that: -- any Given-When-Then step can be implemented by a lambda expression or a method reference; +- any Given-When-Then step can be implemented by a lambda or a method reference; - you manipule the same SUT type from the beginning to the end, because the `sut` type is determined during the *Given* step, until the end; - there is no need to instantiate the `sut` object, even if it is allowed by the `givenSut(sutInstance)` alternate end point, as below; - the call to any `given()` method is optional; @@ -125,8 +125,8 @@ givenSutClass(SystemUnderTest.class) }).and(() -> { // another Given step }) // to be repeated as many times as you need -.when(sut -> { ... }) -.then(result -> { ... }); +.when(sut -> {}) +.then(result -> {}); ``` For example, you can separate the preparation between the SUT and the other fixtures. @@ -136,8 +136,8 @@ givenSutClass(SystemUnderTest.class) // SUT preparation in a Given step }).and(() -> { // Other fixtures preparation in another Given step -}).when(sut -> { ... }) -.then(result -> { ... }); +}).when(sut -> {}) +.then(result -> {}); ``` If some fixtures are the arguments of the method to be tested, you may prefer the following alternate syntaxes. @@ -148,7 +148,7 @@ givenSutClass(SystemUnderTest.class) // Where this argument is built. }).andArgument("argument already ready to be used", DataProvider::choosenDataSet) .when(SystemUnderTest::nonVoidMethodWithArguments) -.then(result -> { ... }); +.then(result -> {}); ``` The arguments will be injected as argument values when the method to be tested is called. As you can guess, `Data::choosenDataSet` is a method reference. @@ -161,8 +161,8 @@ givenSutClass(SystemUnderTest.class) // Put the SUT in a known state. }).and("a specific data set", () -> { // Prepare other fixtures. -}).when(sut -> { ... }) -.then(result -> { ... }); +}).when(sut -> {}) +.then(result -> {}); ``` ## Event @@ -183,8 +183,8 @@ To write very simple tests, you might want to directly attack the system under t import static testasyouthink.TestAsYouThink.when; ... -when(() -> sut.targetMethod(oneOrMoreArguments)).then(...); // or... -when(SystemUnderTest::targetMethod).then(...); // without arguments to be passed to the target method +when(() -> systemUnderTest.targetMethod(oneOrMoreArguments)).then(...); // or... +when(systemUnderTest::targetMethod).then(...); // without arguments to be passed to the target method ``` ### Avoid ambiguous method calls @@ -228,7 +228,6 @@ givenSutClass(SystemUnderTest.class) You can also separate the result expectations in detached blocks. ```java givenSutClass(SystemUnderTest.class) -.given(() -> { ... }) .when(sut -> { return sut.nonVoidMethod(); }) .then(result -> { // an expectation @@ -255,7 +254,6 @@ givenSutClass(SystemUnderTest.class) You are encouraged to explain the system under test behavior by specifying your expectations. What is the expected behavior in the current situtation? ```java givenSutClass(SystemUnderTest.class) -.given(() -> { ... }) .when(sut -> { ... }) .then("first specified expectation", result -> { // Expectation as specified @@ -273,7 +271,6 @@ If a method signature contains a `throws` clause with a checked, compile-time ex Because the failure testing is an important part of your use cases, you can verify the behavior of the system under test when it is used ouside operating conditions. ```java givenSutClass(SystemUnderTest.class) -.given(() -> { ... }) .whenSutRunsOutsideOperatingConditions(sut -> { // where an event causes a failure }).thenItFails().becauseOf(ExpectedFailure.class).withMessage("expected message"); @@ -301,7 +298,7 @@ givenSutClass(SystemUnderTest.class) .thenSutRepliesWithin(Duration.ofMinutes(3); ``` -The advantage of TestAsYouThink is that the time limit is only applied to the tested event, while [JUnit](https://github.com/junit-team/junit4/wiki/timeout-for-tests) applies its `timeout` to the whole test method with its `@Test` annotation. [JUnit 5](http://junit.org/junit5/docs/snapshot/user-guide/) will propose an `assertTimeout(duration, lambda)` method that returns the lamba expression result, but such a syntax amalgamates irremediably the expectations and the event. +The advantage of TestAsYouThink is that the time limit is only applied to the tested event, while [JUnit](https://github.com/junit-team/junit4/wiki/timeout-for-tests) applies its `timeout` to the whole test method with its `@Test` annotation. [JUnit 5](http://junit.org/junit5/docs/snapshot/user-guide/) will propose an `assertTimeout(duration, lambda)` method that returns the lamba result, but such a syntax amalgamates irremediably the expectations and the event. # Release Notes From e802c2db41f5c49838c6947f6e704b29687b1dd2 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 13:47:19 +0200 Subject: [PATCH 12/12] Release the Maven artifacts. --- pom.xml | 2 +- test-as-you-think-core/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fcc902b..32dddb9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.xapn test-as-you-think-project - 0.4 + 0.4.1 pom ${project.groupId}:${project.artifactId}:${project.version}:${project.packaging} The TestAsYouThink project aims to provide tooling to improve test code quality and to make testing diff --git a/test-as-you-think-core/pom.xml b/test-as-you-think-core/pom.xml index e605ed0..b4a96c2 100644 --- a/test-as-you-think-core/pom.xml +++ b/test-as-you-think-core/pom.xml @@ -5,7 +5,7 @@ com.github.xapn test-as-you-think-project - 0.4 + 0.4.1 test-as-you-think-core