Tablasco

Tablasco Parent Project

License

License

GroupId

GroupId

com.goldmansachs.tablasco
ArtifactId

ArtifactId

tablasco
Last Version

Last Version

2.5.0
Release Date

Release Date

Type

Type

pom
Description

Description

Tablasco
Tablasco Parent Project
Project URL

Project URL

https://github.com/goldmansachs/tablasco/
Project Organization

Project Organization

Goldman Sachs
Source Code Management

Source Code Management

https://github.com/goldmansachs/tablasco/

Download tablasco

Filename Size
tablasco-2.5.0.pom 5 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.goldmansachs.tablasco/tablasco/ -->
<dependency>
    <groupId>com.goldmansachs.tablasco</groupId>
    <artifactId>tablasco</artifactId>
    <version>2.5.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.goldmansachs.tablasco/tablasco/
implementation 'com.goldmansachs.tablasco:tablasco:2.5.0'
// https://jarcasting.com/artifacts/com.goldmansachs.tablasco/tablasco/
implementation ("com.goldmansachs.tablasco:tablasco:2.5.0")
'com.goldmansachs.tablasco:tablasco:pom:2.5.0'
<dependency org="com.goldmansachs.tablasco" name="tablasco" rev="2.5.0">
  <artifact name="tablasco" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.goldmansachs.tablasco', module='tablasco', version='2.5.0')
)
libraryDependencies += "com.goldmansachs.tablasco" % "tablasco" % "2.5.0"
[com.goldmansachs.tablasco/tablasco "2.5.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • tablasco-junit
  • tablasco-spark

Tablasco

What is it?

Tablasco is a JUnit rule that adds table verification to your unit tests. The three main features of Tablasco combine to create tests that are both comprehensive and easy to maintain.

1. Fast and efficient table verification algorithm

Tablasco's table verification algorithm can process tens of thousands of table rows out-of-the-box, and many more with custom configuration. Verification can be configured to control behavior such as verifying row order, ignoring headers and applying tolerance to floating-point values.

2. Human readable HTML break reports

Each test produces a color-coded HTML report showing how the actual and expected tables differed helping developers quickly identify problems. Output can be configured to support large datasets by hiding matched rows and collapsing similar breaks.

Example HTML report

3. Automatic baseline management

Each Tablasco test is backed by a text file containing expected results; this baseline file is normally saved with the code in version control. If a test fails because of a change that caused an expected difference the test can be rebased to update the text file with the new results.

Usage

The two most important Tablasco classes to be familiar with are TableVerifier and VerifiableTable.

TableVerifier

TableVerifier is a JUnit rule that needs to be defined in each Tablasco test class:

@Rule
public final TableVerifier tableVerifier = new TableVerifier()
    .withExpectedDir("src/test/resources")
    .withOutputDir("target");

JUnit, by design, ensures that each test method has its own instance of TableVerifier and Tablasco takes advantage of this to offer a fluent API that allows configuration to cascade from the project, to the class, to the test level. To set project level configuration you can wrap the initialisation code above in a factory method:

@Rule
public final TableVerifier tableVerifier = 
    MyTableVerifierFactory.newTableVerifier();

Configuration that you want to apply at a class level can be set when the field is initialised:

@Rule
public final TableVerifier tableVerifier = 
    MyTableVerifierFactory.newTableVerifier().withHideMatchedRows(true);

And finally, configuration required at the test level can be applied inline:

@Test
public void myTest()
{
    this.tableVerifier.withTolerance(0.1d).verify(tables);
}

VerifiableTable

The VerifiableTable interface is an abstract definition of a table that Tablasco understands. Tests need to adapt the data they are verifying to an instance of VerifiableTable. Typically these adapters are shared across tests or even across applications.

Example Test

TableVerifier compares instances of VerifiableTable with the baseline results file; if the tables match the test passes, otherwise the test fails.

@Test
public void tableToBaselineTest()
{
    VerifiableTable table = new MyResultsVerifiableTable(getResults());
    this.tableVerifier.verify("results", table);
}

Rebasing

To rebase a test or suite of tests set the system property rebase=true or configure the verifier directly using .withRebase(). As a precaution to prevent developers accidentally leaving rebase switched on, rebasing tests always fail.

com.goldmansachs.tablasco

Versions

Version
2.5.0
2.4.0
2.3.0
2.2.0
2.1.0
2.0.0