From 40a12dd1f0c1472686c0017c962c4c3768e87afa Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Wed, 12 Jul 2017 10:24:38 +0200 Subject: [PATCH 01/18] Start to develop the 0.4.2 version. --- 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 32dddb9..f7435fc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.xapn test-as-you-think-project - 0.4.1 + 0.4.2-SNAPSHOT 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 b4a96c2..c058e0c 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.1 + 0.4.2-SNAPSHOT test-as-you-think-core From 4ed7ae75a0860ebf0da530393affd8e0d7d9ee18 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sun, 25 Jun 2017 13:34:00 +0200 Subject: [PATCH 02/18] Enable code instrumentation and check branch and line coverage rates with Cobertura. - To check code coverage: mvn clean verify --- test-as-you-think-core/pom.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test-as-you-think-core/pom.xml b/test-as-you-think-core/pom.xml index c058e0c..aa2b239 100644 --- a/test-as-you-think-core/pom.xml +++ b/test-as-you-think-core/pom.xml @@ -14,6 +14,38 @@ https://xapn.github.io/test-as-you-think + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + 85 + 85 + true + 85 + 85 + 85 + 85 + + + + + + + clean + + check + + + + + + + junit From a95207200e9860df2c785d5bf5a3a2a139413325 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sun, 25 Jun 2017 13:36:53 +0200 Subject: [PATCH 03/18] Fix the line coverage for some classes. --- .../java/testasyouthink/TestAsYouThink.java | 2 +- .../testasyouthink/GivenWhenThenTest.java | 38 +++++++++++++++++-- 2 files changed, 35 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 f84e5f5..c86d409 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 @@ -42,7 +42,7 @@ public class TestAsYouThink { try { return new GivenWhenSteps<>(sutClass.newInstance()); } catch (Exception exception) { - throw new RuntimeException(exception.getMessage()); + throw new RuntimeException(exception.getMessage(), exception); } } diff --git a/test-as-you-think-core/src/test/java/testasyouthink/GivenWhenThenTest.java b/test-as-you-think-core/src/test/java/testasyouthink/GivenWhenThenTest.java index 35adcd6..f1a4e98 100644 --- a/test-as-you-think-core/src/test/java/testasyouthink/GivenWhenThenTest.java +++ b/test-as-you-think-core/src/test/java/testasyouthink/GivenWhenThenTest.java @@ -22,17 +22,20 @@ package testasyouthink; -import testasyouthink.fixture.GivenWhenThenDefinition; -import testasyouthink.fixture.SystemUnderTest; import org.junit.After; import org.junit.Before; import org.junit.Test; +import testasyouthink.fixture.GivenWhenThenDefinition; +import testasyouthink.fixture.SystemUnderTest; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.reset; +import static org.easymock.EasyMock.verify; import static testasyouthink.TestAsYouThink.givenSut; import static testasyouthink.TestAsYouThink.givenSutClass; import static testasyouthink.fixture.GivenWhenThenDefinition.orderedSteps; -import static org.assertj.core.api.Assertions.assertThat; -import static org.easymock.EasyMock.verify; public class GivenWhenThenTest { @@ -119,4 +122,31 @@ public void should_verify_expectations_on_the_sut_given_a_void_method() { assertThat(sut.getState()).isNotNull(); }); } + + @Test + public void should_fail_creating_sut_instance() { + // GIVEN + reset(givenWhenThenDefinitionMock); + replay(givenWhenThenDefinitionMock); + + // WHEN + Throwable thrown = catchThrowable(() -> givenSutClass(SystemUnderTestFailingToBeInstantiated.class) + .when(SystemUnderTestFailingToBeInstantiated::voidMethod) + .then(() -> givenWhenThenDefinitionMock.thenTheActualResultIsInKeepingWithTheExpectedResult())); + + // THEN + assertThat(thrown) + .isInstanceOf(RuntimeException.class) + .hasMessage("Impossible to instantiate it!") + .hasCauseInstanceOf(Exception.class); + } + + static class SystemUnderTestFailingToBeInstantiated { + + SystemUnderTestFailingToBeInstantiated() throws Exception { + throw new Exception("Impossible to instantiate it!"); + } + + void voidMethod() {} + } } From f3ae43917c01275e7dcee9af3d887c3fff25b10c Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sun, 25 Jun 2017 20:29:17 +0200 Subject: [PATCH 04/18] Fix the line coverage for some classes. - Make the default constructor private for classes that have only static methods to prevent these classes from being instantiated. It was made for the Assertions class at first, and for some other ones to generalize this good practice and to be consistent. Another effect of the change is to shift the Cobertura red line from the the class declaration line to the private constructor declaration line. - Exclude the testasyouthink.verification.Assertions flat class from the Cobertura's scan while checking rates. This exclusion will be allowed to be removed if more *Assert classes are created. Notice that expects a filesystem relative path to the '.class' file (Cf. http://www.mojohaus.org/cobertura-maven-plugin/usage.html#Check) instead of the full qualified name of the class. - Another way to fix the previous issue without exclusion is to put in the concerned class a static initialization block that calls the private constructor. But such a piece of code is useless outside Cobertura. Useful threads: - http://cobertura.996293.n3.nabble.com/coverage-report-error-of-class-with-static-methods-only-td1738.html - https://stackoverflow.com/questions/25900958/cobertura-exclude-vs-ignore --- test-as-you-think-core/pom.xml | 5 +++++ .../src/main/java/testasyouthink/TestAsYouThink.java | 2 ++ .../main/java/testasyouthink/verification/Assertions.java | 4 +++- .../java/testasyouthink/verification/RunnableAssert.java | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test-as-you-think-core/pom.xml b/test-as-you-think-core/pom.xml index aa2b239..affa0ca 100644 --- a/test-as-you-think-core/pom.xml +++ b/test-as-you-think-core/pom.xml @@ -22,6 +22,11 @@ cobertura-maven-plugin 2.7 + + + testasyouthink/verification/Assertions.class + + 85 85 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 c86d409..9787f36 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 @@ -34,6 +34,8 @@ public class TestAsYouThink { private static Functions functions = Functions.INSTANCE; private static ThenStepFactory thenStepFactory = ThenStepFactory.INSTANCE; + private TestAsYouThink() {} + public static <$SystemUnderTest> Given<$SystemUnderTest> givenSut($SystemUnderTest systemUnderTest) { return new GivenWhenSteps<>(systemUnderTest); } diff --git a/test-as-you-think-core/src/main/java/testasyouthink/verification/Assertions.java b/test-as-you-think-core/src/main/java/testasyouthink/verification/Assertions.java index 12c8b60..f9acb21 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/verification/Assertions.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/verification/Assertions.java @@ -24,7 +24,9 @@ public class Assertions { + private Assertions() {} + public static RunnableAssert assertThat(Runnable runnable) { - return new RunnableAssert(runnable); + return RunnableAssert.assertThat(runnable); } } diff --git a/test-as-you-think-core/src/main/java/testasyouthink/verification/RunnableAssert.java b/test-as-you-think-core/src/main/java/testasyouthink/verification/RunnableAssert.java index 94a6e87..9761952 100644 --- a/test-as-you-think-core/src/main/java/testasyouthink/verification/RunnableAssert.java +++ b/test-as-you-think-core/src/main/java/testasyouthink/verification/RunnableAssert.java @@ -34,7 +34,7 @@ public class RunnableAssert extends AbstractAssert { - RunnableAssert(Runnable actual) { + private RunnableAssert(Runnable actual) { super(actual, RunnableAssert.class); } From 4e63cf5c75b0a6cfb187c67552995c6260a2a7bb Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sun, 25 Jun 2017 22:16:26 +0200 Subject: [PATCH 05/18] Centralize the Maven Cobertura plugin configuration at a higher level. --- pom.xml | 27 +++++++++++++++++++++++++++ test-as-you-think-core/pom.xml | 21 --------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 4227a18..7eea7b1 100644 --- a/pom.xml +++ b/pom.xml @@ -278,6 +278,33 @@ exec-maven-plugin 1.6.0 + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + 85 + 85 + true + 85 + 85 + 85 + 85 + + + + + + + clean + + check + + + + diff --git a/test-as-you-think-core/pom.xml b/test-as-you-think-core/pom.xml index affa0ca..be40001 100644 --- a/test-as-you-think-core/pom.xml +++ b/test-as-you-think-core/pom.xml @@ -16,37 +16,16 @@ - org.codehaus.mojo cobertura-maven-plugin - 2.7 testasyouthink/verification/Assertions.class - - 85 - 85 - true - 85 - 85 - 85 - 85 - - - - - - clean - - check - - - From 0f1ef9d9bee02495698f550cdefe31106457d148 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 15:49:31 +0200 Subject: [PATCH 06/18] Generate or update the table of content of the documentation before releasing. - To use it, invoke the 'before-release' Maven profile. mvn initialize -Pbefore-release Then commit the TOC update. - Prerequisite: markdown-toc must be installed. For more information: https://github.com/jonschlinkert/markdown-toc --- pom.xml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pom.xml b/pom.xml index f7435fc..4e7cb97 100644 --- a/pom.xml +++ b/pom.xml @@ -272,11 +272,46 @@ versions-maven-plugin 2.4 + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + before-release + + false + + + + + org.codehaus.mojo + exec-maven-plugin + false + + + generate_toc + initialize + + exec + + + + markdown-toc + -i README.md + + + + + + + release From 33ce94c0cc5a619b4614316e909494849d02b32d Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Wed, 28 Jun 2017 01:16:58 +0200 Subject: [PATCH 07/18] Check code coverage only if needed. - Isolate the code coverage process because as the Maven Cobertura plugin has its own lifecycle, it runs all the tests twice in the same build and the build takes twice as long. - As of now, to check code coverage: mvn clean verify -Pcoverage --- pom.xml | 11 +++++++++++ test-as-you-think-core/pom.xml | 28 +++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 7eea7b1..abcf945 100644 --- a/pom.xml +++ b/pom.xml @@ -310,6 +310,17 @@ + + coverage + + + + org.codehaus.mojo + cobertura-maven-plugin + + + + before-release diff --git a/test-as-you-think-core/pom.xml b/test-as-you-think-core/pom.xml index be40001..042db35 100644 --- a/test-as-you-think-core/pom.xml +++ b/test-as-you-think-core/pom.xml @@ -15,19 +15,21 @@ https://xapn.github.io/test-as-you-think - - - org.codehaus.mojo - cobertura-maven-plugin - - - - testasyouthink/verification/Assertions.class - - - - - + + + + org.codehaus.mojo + cobertura-maven-plugin + + + + testasyouthink/verification/Assertions.class + + + + + + From 8e9e2593a57985a4e27eab682ee64f2367a55669 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 16:16:10 +0200 Subject: [PATCH 08/18] Commit the TOC update juste after generating it. - It is still possible to generate and commit the TOC in two separated steps. - To generate the TOC only: mvn exec:exec@generate_toc -Pbefore-release -pl . - To commit the TOC only: mvn exec:exec@commit_toc -Pbefore-release -pl . NB: The '-pl .' option is required to apply the command only to the root aggregation module and to not propagate the command to the child modules. --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 4e7cb97..4227a18 100644 --- a/pom.xml +++ b/pom.xml @@ -307,6 +307,19 @@ -i README.md + + commit_toc + initialize + + exec + + + git + + commit README.md -m 'Update the table of content of the documentation.' + + + From 1673b44fd17d729444180365de8c957d28b39e85 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 1 Jul 2017 21:49:51 +0200 Subject: [PATCH 09/18] Upload Cobertura reports to codecov.io while building with Travis CI. --- .travis.yml | 3 +++ pom.xml | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 52a562d..f2d7b65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,3 +25,6 @@ before_install: - echo "====== DEPENDENCIES - End ======" jdk: - oraclejdk8 +script: "mvn cobertura:cobertura" +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/pom.xml b/pom.xml index abcf945..c216d70 100644 --- a/pom.xml +++ b/pom.xml @@ -293,6 +293,11 @@ 85 85 + + html + xml + + From be661e5a7e8b429ce76f3948a7f2591bccfa03f5 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 16:24:41 +0200 Subject: [PATCH 10/18] Write the release note. --- README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eb1591f..a3b512f 100644 --- a/README.md +++ b/README.md @@ -300,26 +300,37 @@ givenSutClass(SystemUnderTest.class) 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 +# Releases -## Version 0.4.1: Travis CI as a continuous integration platform +## Versioning + +To understand how version numbers change, please read the [Semantic Versioning](http://semver.org/). + +## Release Notes + +### 0.4.2 version: Cobertura as a code coverage analyzer + +- Generate the documentation TOC updating with [markdown-toc](https://github.com/jonschlinkert/markdown-toc) and commit the documentation change while building with Maven. +- Check code coverage with [Cobertura](http://cobertura.github.io/cobertura/) and publish reports to [Codecov](https://codecov.io/) while building with [Travis CI](https://travis-ci.org). + +### 0.4.1 version: 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 +### 0.4 version: Time limit as an expectation - Expect that the system under test replies within a time limit. - Resolve ambiguous method calls in relation to using expression lambdas. - Start to write a test with the when step. -## Version 0.3: TestAsYouThink as a Maven distributed OSS library +### 0.3 version: TestAsYouThink as a Maven distributed OSS library -- Rename the API to **TestAsYouThink**. +- Rename the API to *TestAsYouThink*. - Choose an open source license. - Publish artifacts to Maven Central. - Check version updates. -## Version 0.2: Test fixtures as method arguments +### 0.2 version: Method arguments as test fixtures - Include a data as a method argument during the preparation phase. - Include two data as method arguments during the preparation phase. @@ -329,7 +340,7 @@ The advantage of TestAsYouThink is that the time limit is only applied to the te - Verify failures while invoking methods with arguments. - Verify the expected exception and the expected message separately. -## Version 0.1: Given-When-Then as a canvas +### 0.1 version: Given-When-Then as a canvas - Write an unit or integration test by using the Given-When-Then canvas and full sequence. - Delegate the system under test instantiation to the API. From 9a134c1e36f356b90bdf6311e99b6fb65c343522 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sat, 24 Jun 2017 19:33:55 +0200 Subject: [PATCH 11/18] Update the documentation. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a3b512f..f1d7fed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 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) [![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) +Social coding | [![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) @@ -46,7 +46,7 @@ Social | [![Twitter URL](https://img.shields.io/twitter/url/http/sh Why to name this API *TestAsYouThink*? The goal of *TestAsYouThink* is to map out the road from a new software functionality idea to its contractualized achievement as an executable test, while preserving product developers against known pitfalls. According to this perspective, any pitfall is likely to extend the developer's journey and to put him off his target. By anticipating such pitfalls, *TestAsYouThink* will be the best way to reduce the distance to proper, durable testing. -Moreover *TestAsYouThink* uses the Given-When-Then canvas as a formal guide to compose tests. This canvas originally comes from [Gherkin](https://sites.google.com/site/unclebobconsultingllc/the-truth-about-bdd) that is a grammatical protocol used in the [Behavior-Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) method to write test scenarii in a business human-readable way by specifying a software behavior basing on concrete examples. Given-When-Then serves to divide any test into the three eponym steps. This canvas is implemented by the *TestAsYouThink* project to deliver a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) style fluent API. +Moreover *TestAsYouThink* uses the [Given-When-Then](https://www.agilealliance.org/glossary/gwt/) canvas as a formal guide to compose tests. This canvas originally comes from [Gherkin](https://sites.google.com/site/unclebobconsultingllc/the-truth-about-bdd) that is a grammatical protocol used in the [Behavior-Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) method to write test scenarii in a business human-readable way by specifying a software behavior basing on concrete examples. [Given-When-Then](https://www.agilealliance.org/glossary/gwt/) serves to divide any test into the three eponym steps. This canvas is implemented by the *TestAsYouThink* project to deliver a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) style fluent API. # Getting Started @@ -70,14 +70,14 @@ givenSutClass(SystemUnderTest.class) .then(() -> {}); ``` -Let us complete the previous scenario with a very simple example of what you can do, while testing a non-void method of your system under test. +Let us complete the previous scenario with a very simple example of what you can do, while testing a non-void method of your system under test (abbreviated as SUT later). ```java import static testasyouthink.TestAsYouThink.givenSutClass; ... givenSutClass(SystemUnderTest.class) .given(sut -> { - // Where you prepare the context that defines the initial state of the system under test (SUT). + // Where you prepare the context that defines the initial state of the SUT. DataSet dataSet = new DataSet(...); sut.setAnyAttribute(...); }).when(sut -> { @@ -90,9 +90,10 @@ givenSutClass(SystemUnderTest.class) ``` Notice that: -- any Given-When-Then step can be implemented by a lambda or a method reference; +- the `TestAsYouThink` class is the only one end point of the API; +- 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; +- there is no need to instantiate the `sut` object, even if it is allowed by the `givenSut(sutInstance)` alternate end point method, as below; - the call to any `given()` method is optional; - you manipule the same `result` type until the end, because the `result` type is determined during the *When* step; - you cannot inadvertently make a fake test that would verify nothing, because any `then()` method is always a sequence termination. @@ -355,4 +356,4 @@ To understand how version numbers change, please read the [Semantic Versioning]( # License -*Test As You Think* is distributed under the GNU LGPLv3 license. The LGPLv3 license is included in the LICENSE.txt file. More information about this license is available at http://www.gnu.org. +*TestAsYouThink* is distributed under the GNU LGPLv3 license. The LGPLv3 license is included in the LICENSE.txt file. More information about this license is available at http://www.gnu.org. From 2c0d4faff6132cf20a23e9cbfb8b39a5e51a35c0 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Wed, 28 Jun 2017 01:03:15 +0200 Subject: [PATCH 12/18] Add a permalink to the documentation. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f1d7fed..b94606f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Software factory | [![Maven Central](https://img.shields.io/maven-central/v/o 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 coding | [![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) +Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to get [analytics data](https://goo.gl/#analytics/goo.gl/XqS4Zf/all_time). + - [Fluent testing and added value](#fluent-testing-and-added-value) From 55a77962b61090c8f80f2a4ad848d09a133df7e0 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Sun, 9 Jul 2017 13:53:39 +0200 Subject: [PATCH 13/18] Add a QR code to the documentation. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b94606f..58bb9c2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Software factory | [![Maven Central](https://img.shields.io/maven-central/v/o 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 coding | [![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) -Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to get [analytics data](https://goo.gl/#analytics/goo.gl/XqS4Zf/all_time). +Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to get [analytics data](https://goo.gl/#analytics/goo.gl/XqS4Zf/all_time). You can also use this [QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf). +![QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf) From 4de3dddcddfc08fed6de889717e6f924296994f5 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Tue, 11 Jul 2017 21:21:00 +0200 Subject: [PATCH 14/18] Add links to code examples of use. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 58bb9c2..fd7a46f 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,12 @@ givenSutClass(SystemUnderTest.class) 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. +# Code Examples + +You can find concrete examples of use in the following repositories. +- [TestAsYouThink examples](https://github.com/xapn/test-as-you-think-examples), with didactic, funny examples of use: do not hesitate to add your own examples being creative. +- [Fizz-Buzz](https://xapn.github.io/fizz-buzz), a coding dojo with many JUnit tests. + # Releases ## Versioning From 4cae7eb1846d6e213d0fafaccc77fb6d0ca67b65 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Tue, 11 Jul 2017 15:47:21 +0200 Subject: [PATCH 15/18] Update the TOC. --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd7a46f..fbf249f 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,16 @@ Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to - [Expected failures](#expected-failures) - [Unexpected failures](#unexpected-failures) + [Time limit](#time-limit) -- [Release Notes](#release-notes) - * [Version 0.4: Time limit as an expectation](#version-04-time-limit-as-an-expectation) - * [Version 0.3: TestAsYouThink as a Maven distributed OSS library](#version-03-testasyouthink-as-a-maven-distributed-oss-library) - * [Version 0.2: Test fixtures as method arguments](#version-02-test-fixtures-as-method-arguments) - * [Version 0.1: Given-When-Then as a canvas](#version-01-given-when-then-as-a-canvas) +- [Code Examples](#code-examples) +- [Releases](#releases) + * [Versioning](#versioning) + * [Release Notes](#release-notes) + + [0.4.2 version: Cobertura as a code coverage analyzer](#042-version-cobertura-as-a-code-coverage-analyzer) + + [0.4.1 version: Travis CI as a continuous integration platform](#041-version-travis-ci-as-a-continuous-integration-platform) + + [0.4 version: Time limit as an expectation](#04-version-time-limit-as-an-expectation) + + [0.3 version: TestAsYouThink as a Maven distributed OSS library](#03-version-testasyouthink-as-a-maven-distributed-oss-library) + + [0.2 version: Method arguments as test fixtures](#02-version-method-arguments-as-test-fixtures) + + [0.1 version: Given-When-Then as a canvas](#01-version-given-when-then-as-a-canvas) - [License](#license) From 7e7d152d62a554b1f46cad60bf1055d14e96cd98 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Tue, 11 Jul 2017 22:55:54 +0200 Subject: [PATCH 16/18] Update badges. - Fix the Twitter, Maven Central badges. - Add the Codecov badges. - Add a badge for GitHub contributors. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbf249f..36c5383 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ 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) [![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) +Software factory | [![Maven Central](https://img.shields.io/maven-central/v/com.github.xapn/test-as-you-think-project.svg)](http://search.maven.org/#search%7Cga%7C1%7Ctest-as-you-think) master: { [![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), [![codecov](https://codecov.io/gh/xapn/test-as-you-think/branch/master/graph/badge.svg)](https://codecov.io/gh/xapn/test-as-you-think) } develop: { [![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), [![codecov](https://codecov.io/gh/xapn/test-as-you-think/branch/develop/graph/badge.svg)](https://codecov.io/gh/xapn/test-as-you-think/branch/develop) } [![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) 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 coding | [![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) +Licensing | [![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) [![GitHub contributors](https://img.shields.io/github/contributors/xapn/test-as-you-think.svg)](https://github.com/xapn/test-as-you-think/graphs/contributors) +Social coding | [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/xapn/test-as-you-think.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fxapn%2Ftest-as-you-think) [![Twitter Follow](https://img.shields.io/twitter/follow/xengineer.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=xengineer) [![GitHub stars](https://img.shields.io/github/stars/xapn/test-as-you-think.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) [![GitHub watchers](https://img.shields.io/github/watchers/xapn/test-as-you-think.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) [![GitHub forks](https://img.shields.io/github/forks/xapn/test-as-you-think.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think/network) Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to get [analytics data](https://goo.gl/#analytics/goo.gl/XqS4Zf/all_time). You can also use this [QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf). ![QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf) From 03101beed8058566a64323eb2799dcb21833d100 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Wed, 12 Jul 2017 09:27:18 +0200 Subject: [PATCH 17/18] Replace the Twitter URL with the Google shortened URL. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36c5383..c1fe191 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Matter | Badges Software factory | [![Maven Central](https://img.shields.io/maven-central/v/com.github.xapn/test-as-you-think-project.svg)](http://search.maven.org/#search%7Cga%7C1%7Ctest-as-you-think) master: { [![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), [![codecov](https://codecov.io/gh/xapn/test-as-you-think/branch/master/graph/badge.svg)](https://codecov.io/gh/xapn/test-as-you-think) } develop: { [![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), [![codecov](https://codecov.io/gh/xapn/test-as-you-think/branch/develop/graph/badge.svg)](https://codecov.io/gh/xapn/test-as-you-think/branch/develop) } [![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) 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) Licensing | [![License: GNU LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0) [![GitHub contributors](https://img.shields.io/github/contributors/xapn/test-as-you-think.svg)](https://github.com/xapn/test-as-you-think/graphs/contributors) -Social coding | [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/xapn/test-as-you-think.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fxapn%2Ftest-as-you-think) [![Twitter Follow](https://img.shields.io/twitter/follow/xengineer.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=xengineer) [![GitHub stars](https://img.shields.io/github/stars/xapn/test-as-you-think.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) [![GitHub watchers](https://img.shields.io/github/watchers/xapn/test-as-you-think.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) [![GitHub forks](https://img.shields.io/github/forks/xapn/test-as-you-think.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think/network) +Social coding | [![Twitter URL](https://img.shields.io/twitter/url/https/github.com/xapn/test-as-you-think.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgoo.gl%2FXqS4Zf) [![Twitter Follow](https://img.shields.io/twitter/follow/xengineer.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=xengineer) [![GitHub stars](https://img.shields.io/github/stars/xapn/test-as-you-think.svg?style=social&label=Star)](https://github.com/xapn/test-as-you-think/stargazers) [![GitHub watchers](https://img.shields.io/github/watchers/xapn/test-as-you-think.svg?style=social&label=Watch)](https://github.com/xapn/test-as-you-think/watchers) [![GitHub forks](https://img.shields.io/github/forks/xapn/test-as-you-think.svg?style=social&label=Fork)](https://github.com/xapn/test-as-you-think/network) Please use this [permalink](https://goo.gl/XqS4Zf) to share this web page and to get [analytics data](https://goo.gl/#analytics/goo.gl/XqS4Zf/all_time). You can also use this [QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf). ![QR code](https://chart.googleapis.com/chart?cht=qr&chs=150x150&choe=UTF-8&chld=H&chl=https://goo.gl/XqS4Zf) From 6166f57e5d4ae9174561a7339eaefc0350cba050 Mon Sep 17 00:00:00 2001 From: Xavier Pigeon Date: Wed, 12 Jul 2017 10:51:16 +0200 Subject: [PATCH 18/18] 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 c216d70..794cfb0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.xapn test-as-you-think-project - 0.4.2-SNAPSHOT + 0.4.2 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 042db35..1404ee7 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.2-SNAPSHOT + 0.4.2 test-as-you-think-core