Fluent assertions library for Java

Overview

Deep Dive Assertions

Deep Dive is an assertion library for Java. It offers a fluent API which allows you to dive deep, i.e. going back and forth between different assertion objects.

TL;DR

Tests written with Deep Dive look like this:

import java.io.File;
import static java.nio.StandardCharsets.UTF_8;
import static deepdive.ExpectThat.expectThat;		
	
// inside a test method:		
File dir = ...                     // dir is a File object which we expect to be a directory  
expectThat(dir)                    // starting with a deepdive.actual.io.FileActual to test the directory
    .isDirectory()                 // test a File property
    .name()                        // dive into a deepdive.actual.lang.StringActual to test the File name
    	.startsWith("test_")       // test a File name property
    	.endsWith("_files")        // test a File name property
    	.back()                    // back to the FileActual
    .set().childFile("result.txt") // replace the actual File value with a child File
    .exists()                      // test a File property
    .isFile()                      // test a File property
    .not().isHidden()              // negate any available assertion by a preceding not() 
    .length()                      // dive into a deepdive.actual.lang.LongActual to the test the file length
        .greater(50)               // test a File length property
        .back()                    // back to the FileActual
    .read(UTF_8).lineIterator()    // read file content as lines and dive into a deepdive.actual.util.StringIteratorActual 
        .next()                    // dive into a StringActual for the first line 
            .startsWith("Hold your breath") // tests a line property
            .back()                // back to the StringIteratorActual
        .skip(5)                   // skip 5 lines
        .next()                    // dive into a StringActual to test the next line
            .isLowerCase()         // test a line property
            .back()                // back to the StringIteratorActual
    	.not().hasNext();          // test for iteration end: done!

License

Deep Dive can be used under the terms of the Gnu Public License v3 or the Apache 2.0 license, see License.md for details.

Dependencies

Deep Dive requires Java 8+ and has no external dependencies. It works great with test engines like JUnit or TestNG, just transition over from JUnit or TestNG assertions to the ones offered by Deep Dive.

How to use

Download the latest release and include the Deep Dive jar into your classpath. The user guide explains the details on how to use Deep Dive.

Why to use

Like other Java assertions libraries (e.g. FEST Assert, AssertJ and Google Truth) Deep Dive provides a fluent API to state assertions. But it goes beyond those libraries

  • by allowing to dive deep, i.e. going back and forth between different assertion objects,
  • providing not-mode to easily negate any assertion provided by the API
  • therefore resulting in a small library (~250K) with great assertion power .

For further details please dive into Motivation.md.

Limitations

Deep Dive makes heavy use of type parameters and recursive type bounds. The Eclipse Compiler for Java (ECJ) used by Eclipse IDE seems to be challenged by this. Therefore you may experience compile errors when diving too deep into assertion objects. javac from the JDK is not affected.

You might also like...

Advanced Java library for integration testing, mocking, faking, and code coverage

Codebase for JMockit 1.x releases - Documentation - Release notes How to build the project: use JDK 1.8 or newer use Maven 3.6.0 or newer; the followi

Dec 9, 2022

AllPairs4J - an open source Java library for generation of minimal set of test combinations

AllPairs4J AllPairs4J is an open source Java library for generation of minimal set of test combinations. AllPairs4J is a Java port of allpairspy proje

Dec 11, 2022

Yet another Java annotation-based command parsing library, with Dependency Injection inspired by Guice

Commander A universal java command parsing library Building This project uses Gradle. Clone this repository: git clone https://github.com/OctoPvP/Comm

Oct 2, 2022

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.

That feeling you get when you know you can trust your tests Serenity BDD is a library designed to make writing automated acceptance tests easier, and

Dec 28, 2022

CodeSheriff is a simple library that helps you in writing JUnit tests that check the quality of your code

CodeSheriff is a simple library that helps you in writing JUnit tests that check the quality of your code. For example, CodeSheriff may fail because you have methods in your code that have more than X lines of code, or that have complexity greater than Y.

Feb 10, 2022

🔌 Simple library to manipulate HTTP requests/responses and capture network logs made by the browser using selenium tests without using any proxies

🔌 Simple library to manipulate HTTP requests/responses and capture network logs made by the browser using selenium tests without using any proxies

Simple library to manipulate HTTP requests and responses, capture the network logs made by the browser using selenium tests without using any proxies

Oct 23, 2022

Objenesis is a library dedicated to bypass the constructor when creating an object. On any JVM there is.

Objenesis Objenesis is a library dedicated to bypass the constructor when creating an object. On any JVM there is. You can find the website and user d

Jan 2, 2023

Core library of SinoCraft Mods

Core library of SinoCraft Mods

Aug 8, 2022

HATEOAS with HAL for Java. Create hypermedia APIs by easily serializing your Java models into HAL JSON.

hate HATEOAS with HAL for Java. Create hypermedia APIs by easily serializing your Java models into HAL JSON. More info in the wiki. Install with Maven

Oct 5, 2022
Owner
Johannes Döbler
Johannes Döbler
AssertJ is a library providing easy to use rich typed assertions

AssertJ - Fluent assertions for java AssertJ provides a rich and intuitive set of strongly-typed assertions to use for unit testing (with JUnit, TestN

AssertJ 2.3k Dec 30, 2022
AssertJ is a library providing easy to use rich typed assertions

AssertJ - Fluent assertions for java AssertJ provides a rich and intuitive set of strongly-typed assertions to use for unit testing (with JUnit, TestN

AssertJ 2.3k Jan 8, 2023
Never debug a test again: Detailed failure reports and hassle free assertions for Java tests - Power Asserts for Java

Scott Test Reporter for Maven and Gradle Get extremely detailed failure messages for your tests without assertion libraries, additional configuration

Dávid Csákvári 133 Nov 17, 2022
A Java architecture test library, to specify and assert architecture rules in plain Java

ArchUnit is a free, simple and extensible library for checking the architecture of your Java code. That is, ArchUnit can check dependencies between pa

TNG Technology Consulting GmbH 2.5k Jan 2, 2023
Library that allows tests written in Java to follow the BDD style introduced by RSpec and Jasmine.

J8Spec J8Spec is a library that allows tests written in Java to follow the BDD style introduced by RSpec and Jasmine. More details here: j8spec.github

J8Spec 45 Feb 17, 2022
A library for setting up Java objects as test data.

Beanmother Beanmother helps to create various objects, simple and complex, super easily with fixtures for testing. It encourages developers to write m

Jaehyun Shin 113 Nov 7, 2022
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

Testcontainers Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium we

null 6.7k Jan 9, 2023
Roman Beskrovnyi 248 Dec 21, 2022
Playwright is a Java library to automate Chromium, Firefox and WebKit with a single API.

Playwright is a Java library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Microsoft 634 Jan 8, 2023
Java library for the Siren Hypermedia Type Specification

This is a java library to help with the creation and use of Hypermedia entities as specified by the Siren hypermedia specification. See https://github

Erik Serating 23 May 8, 2022