Skip to content

Commit

Permalink
Merge branch 'release/v0.4.1'.
Browse files Browse the repository at this point in the history
  • Loading branch information
xapn committed Jun 24, 2017
2 parents 056085b + e802c2d commit 6abf35d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 35 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: java
cache:
directories:
- ${HOME}/.m2
- ${TRAVIS_BUILD_DIR}/dependencies
addons:
apt:
packages:
- tree
before_install:
- echo ${TRAVIS_BUILD_DIR}
- echo ${PWD}
- echo "====== DEPENDENCIES - Start ======"
- 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
52 changes: 20 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -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) [![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)

<!-- toc -->

Expand Down Expand Up @@ -103,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;
Expand Down Expand Up @@ -138,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.
Expand All @@ -149,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.
Expand All @@ -161,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.

Expand All @@ -174,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
Expand All @@ -196,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
Expand Down Expand Up @@ -241,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
Expand All @@ -268,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
Expand All @@ -286,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");
Expand Down Expand Up @@ -314,10 +298,14 @@ 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

## 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.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.xapn</groupId>
<artifactId>test-as-you-think-project</artifactId>
<version>0.4</version>
<version>0.4.1</version>
<packaging>pom</packaging>
<name>${project.groupId}:${project.artifactId}:${project.version}:${project.packaging}</name>
<description>The TestAsYouThink project aims to provide tooling to improve test code quality and to make testing
Expand All @@ -22,7 +22,7 @@
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.minimalVersion>3.3.9</maven.minimalVersion>
<maven.minimalVersion>3.5.0</maven.minimalVersion>
</properties>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion test-as-you-think-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.xapn</groupId>
<artifactId>test-as-you-think-project</artifactId>
<version>0.4</version>
<version>0.4.1</version>
</parent>

<artifactId>test-as-you-think-core</artifactId>
Expand Down

0 comments on commit 6abf35d

Please sign in to comment.