Skip to content

Latest commit

 

History

History
127 lines (105 loc) · 6.17 KB

README.md

File metadata and controls

127 lines (105 loc) · 6.17 KB

Cirneco logo Cirneco

Easy-to-use extensions for unit test libraries

Source Website: github.com/ozimov/cirneco
JavaDoc Website: ozimov.github.io/cirneco/
Wiki Website: github.com/ozimov/cirneco/wiki

Latest Release: 2.0.0
Latest Artifacts: it.ozimov:java7-hamcrest-matchers:jar:2.0.0, it.ozimov:java8-hamcrest-matchers:jar:2.0.0, it.ozimov:guava-hamcrest-matchers:jar:2.0.0, it.ozimov:mockito-helpers:jar:2.0.0
Continuous Integration:
Maven Central
Build Status Coverage Status codecov.io Codacy Badge

codecov.io

What is Cirneco?

Cirneco is a collection of libraries aimed to make unit test in Java cleaner and easier. The more code you have to write, the highest is the probability to do a mistake. Moreover, we like easy-to-read and concise code, where the method name already embeds all the semantics that you need to explain what you are assuming/asserting.

Hence, in Cirneco we aim to extend the most valuable toolkits for unit test to provide a better developing experience. The current version (Cirneco 2.0.0) only provides some extensions for Hamcrest for Java.

JDK compatibility

Since version 2.0.0, the API is JDK8 compatible.

Extended libraries

We provided some extensions of the Hamcrest library. There are some extra feature for fluent assertions that you may also want to checkout.

There is also a library for Mockito that provides for now only a captor for method results.

Moreover, we provide some []AssertJ](http://joel-costigliola.github.io/assertj/) utilities. Specifically, the JUnitSoftAssertionsRule is extended to support Guava matchers.

Hamcrest extensions

There are some interesting matchers based on Guava library. The next release will focus more on Guava collections and money (the plan would be to use Joda Money or to dirfectly provide the matchers for the JDK8 extension). To use the extensions for a JDK7 compliant project, you can embed the following dependency in your pom.xml

<dependency>
  <groupId>it.ozimov</groupId>
  <artifactId>hamcrest-matchers</artifactId>
  <version>2.0.0</version>
  <scope>test</scope>
</dependency>

There are matchers dedicated to Guava libraries that are JDK7-compliant, that you can import with the following dependency:

<dependency>
  <groupId>it.ozimov</groupId>
  <artifactId>guava-hamcrest-matchers</artifactId>
  <version>2.0.0</version>
  <scope>test</scope>
</dependency>

Some libraries are not using Hamcrest v.2.0.0.0. It may be necessary to explicity remove the dependency of older Hamcrest version. E.g. in a Spring Boot application:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
  <exclusions>
    <exclusion>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Otherwise, just put the Cirneco dependencies before to import these dependencies. I suggest to use Maven dependency tree resolver to detect which library is shipped with Hamcrest 2.0.3.

Mockito extension

As a Mockito user maybe you observed that there are no captor implemented by default for the results provided for the method. In fact, you can only capture method arguments. In the Mockito extension we introduced an implementation of the result captor. To use the extension you can add the following dependency in your pom.xml

<dependency>
  <groupId>it.ozimov</groupId>
  <artifactId>mockito-helpers</artifactId>
  <version>2.0.0</version>
  <scope>test</scope>
</dependency>

AssertJ extension

AssertJ has some useful matchers for Guava users. If you love as we love the JUnit rule that exposes the assertions, i.e. JUnitSoftAssertions. We provide an extended rule, with the very same name, that add the Guava assertions provided by AssertJ.

To use the extension you can add the following dependency in your pom.xml

<dependency>
  <groupId>it.ozimov</groupId>
  <artifactId>assertj-guava</artifactId>
  <version>2.0.0</version>
  <scope>test</scope>
</dependency>

What does it mean Cirneco?

Maybe you are curious about the name Cirneco. Cirneco dell'Etna is a unique dog native of Sicily, Italy. It is very fast and agile, neat and friendly. A Cirneco is also excellent for hunting. So, all the quality we love to have in an API.

============================================== forthebadge forthebadge forthebadge forthebadge