• Stars
    star
    335
  • Rank 125,341 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated 10 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ApprovalTest verification library for Java

Build Status Build Status Maven Central

Contents

ApprovalTests.Java

Capturing Human Intelligence - ApprovalTests is an open source assertion/verification library to aid unit testing.

It is compatible with JUnit 3, 4 & 5 and TestNG.

The jars can be used from JDK 1.8 on up until JDK 18.

What can it be used for?

Approval Tests can be used for verifying objects that require more than a simple assert. They also come prepackaged with utilities for some common java scenarios including

  • HashMaps & Collections
  • Long Strings
  • Log Files
  • JPanels
  • Xml
  • Html
  • Json
  • Getting Legacy Code under tests

Documentation

Missing Documentation?

If there is documentation you wish existed, please add a page request to this issue.

Getting started

New Projects

The best way to get started is download and open one of the starter projects:

These are standard projects and can be imported into any editor or IDE.
They also all have CI with Github actions.

Docs

You might also want to check out the Getting Started Overview

Learning

A great way to learn Approval Tests if you are new to it is to try out the Koans.

How to get it

It's on Maven Central, search for 'approvaltests'.

Maven

If you're using Maven, add this to your pom file:

<dependency>
    <groupId>com.approvaltests</groupId>
    <artifactId>approvaltests</artifactId>
    <version>18.7.1</version>
</dependency>

Gradle

dependencies {
    testImplementation("com.approvaltests:approvaltests:18.7.1")
}

or download the jars from maven central repository

Video Tutorials

You can watch a bunch of short videos on getting started and using ApprovalTests in Java at youtube.

Note: There are a lot of videos about ApprovalTests in .Net They are equally useful for understanding the concepts despite being in a different programming language.

Podcasts

If you prefer auditory learning, you might enjoy the following podcast (Note: Some of these talk about the .net side)

Examples

ApprovalTests eats it own dogfood, so the best examples are in the source code itself.

None the less, Here's a quick look

public class SampleArrayTest
{
  @Test
  public void testList()
  {
    String[] names = {"Llewellyn", "James", "Dan", "Jason", "Katrina"};
    Arrays.sort(names);
    Approvals.verifyAll("", names);
  }
}

snippet source | anchor

Will Produce a File SampleArrayTest.testList.received.txt

[0] = Dan
[1] = James
[2] = Jason
[3] = Katrina
[4] = Llewellyn

snippet source | anchor

Simply rename this to SampleTest.testList.approved.txt and the test will now pass.

Approved File Artifacts

The *.approved.* files must be checked into source your source control. This can be an issue with git as it will change the line endings. The suggested fix is to add *.approved.* binary to your .gitattributes

More Info

No Checked Exceptions Philosophy

Approval Tests follows the no checked exceptions" philosophy. That is, our API only throws runtime exceptions.

LICENSE

Apache 2.0 License

Questions?

twitter: @LlewellynFalco or #ApprovalTests

Developer notes

The suggested way to contribute to ApprovalTests is to pair with Llewellyn
However, if you are set on forking please read these notes

More Repositories

1

ApprovalTests.Net

ApprovalTest verification library for .Net
C#
569
star
2

ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
C++
316
star
3

ApprovalTests.Ruby

Approval Tests for Ruby
Ruby
228
star
4

ApprovalTests.Python

ApprovalTests for python
Python
146
star
5

Approvals.NodeJS

Approval Tests implementation in NodeJS
TypeScript
104
star
6

ApprovalTests.Swift

ApprovalTests for Swift, a powerful alternative to assertions
Swift
88
star
7

go-approval-tests

Go
86
star
8

ApprovalTests.Net.Json

Extends ApprovalTests to allow simple approval of complex models.
C#
27
star
9

ApprovalTests.php

PHP
25
star
10

approval_tests

Approval testing for specs and unit tests
Ruby
16
star
11

ApprovalTests.cpp.Qt

C++
15
star
12

ApprovalTests.Net.Koans

Helpful examples to learn ApprovalTests
C#
14
star
13

ApprovalTests.Dart

Approval Tests implementation in Dart
Dart
11
star
14

ApprovalTests.cpp.StarterProject

Starter project for easy learning and use of ApprovalTests.cpp
C++
11
star
15

ApprovalTests.java.Koans

Java
8
star
16

ApprovalTests.Net.Asp

Easy ways to test Asp & Aps.Mvc pages and routes
C#
8
star
17

ApprovalTests.Python.StarterProject

Starter project for getting approvaltests up and running
Python
7
star
18

ApprovalTests.Net.Wpf

Extends ApprovalTests for approval of WPF through screenshot verification.
C#
7
star
19

ApprovalTests.java.StarterProject

Sample Maven project to get started
Java
6
star
20

GroupLearningFacilitation

Printouts to help facilitate a randori/mob programming session of koans
5
star
21

ApprovalTests.js.StarterProject

Starter project to get going. Mocha/ApprovalTests
PowerShell
5
star
22

ApprovalTests.perl

ApprovalTests for Perl
Perl
5
star
23

ApprovalTests.shell

a tiny implementation of Approval Tests for the cli
Shell
5
star
24

merb_approvals

Ruby
3
star
25

ApprovalTests.Net.WinForms

Extends ApprovalTests for approval of Windows Forms through screenshot verification.
C#
3
star
26

Approvals.Net.WebApi

C#
3
star
27

ApprovalTests.cpp.Qt.StarterProject

C++
3
star
28

Approvals.Net.Excel

C#
2
star
29

ApprovalTests.Net.StatePrinter

Extends ApprovalTests to allow simple approval of complex models using StatePrinter.
C#
2
star
30

ApprovalTests.Net.StarterProject

Starter Vs2017 project with MsTest & ApprovalTests
C#
2
star
31

ApprovalTests.TypeScript.Jest.StarterProject

TypeScript
2
star
32

Approvaltests.Kotlin.StarterProject

Kotlin
2
star
33

ApprovalTests.java.StarterProject.gradle

Clone and Go
Java
2
star
34

ApprovalTests.Objective-C

ApprovalTest verification library for Objective-C
Objective-C
2
star
35

ApprovalTests.Go.StarterProject

Go
2
star
36

ApprovalTests.Net.Xunit

Simplifies xUnit support in ApprovalTests
C#
2
star
37

ApprovalTests.Net.EntityFramework

Extends ApprovalTests to allow approval of EntityFramework Queries
C#
2
star
38

ApprovalTests.plugins.intellij

IntelliJ Plugin for ApprovalTests.Java
Kotlin
2
star
39

Approvaltests.Dart.StarterProject

Starter Project for Approval Tests implementation in Dart
Dart
2
star
40

Approvaltests.Elixir

Elixir
2
star
41

ApprovalTests.cpp.StarterProject.GoogleTests

VS2017 GoogleTest starter project
C++
1
star
42

ApprovalTests.LabVIEW.StarterProject

LabVIEW
1
star
43

ApprovalTests.Dart.Flutter

Dart
1
star
44

ApprovalTests.Net.NHibernate

C#
1
star
45

PackageSettings.java

Package level settings for java
Java
1
star
46

ApprovalTests.pharo.StarterProject

Smalltalk
1
star
47

ApprovalTests.Documentation

ApprovalTests.Documentation
1
star
48

ApprovalTests.Net.NServiceBus

Adds ApprovalTests support to NServiceBus
C#
1
star
49

notes

1
star
50

ApprovalTests.cpp.StarterProject.VisualStudio

1
star
51

ApprovalTests.Scala.StarterProject

Scala
1
star
52

.github

1
star
53

EmptyFiles.Python

Python
1
star
54

ApprovalTests.Swift.StarterProject.MacOs

Swift
1
star
55

ApprovalTests.Net.Rdlc

C#
1
star
56

ApprovalTests.Groovy.StarterProject

Groovy
1
star
57

go-approval-tests-starter-project

clone and go for golang
PowerShell
1
star
58

ApprovalTests.net.StarterProject.core

C#
1
star
59

ApprovalTests.GlamorousToolkit.StarterProject

Smalltalk
1
star
60

ApprovalTests.Ruby.starterproject

Ruby
1
star
61

ApprovalTests.LabVIEW

LabVIEW
1
star
62

ApprovalTests.Net.Aspose

Extends ApprovalTests to allow approval of documents via Aspose.
C#
1
star
63

ApprovalTests.Net.AppConfig

C#
1
star
64

ApprovalTests.Angular.Jest.starterproject

TypeScript
1
star
65

ApprovalTests.lua

Approvals for lua
Lua
1
star
66

approvals.github.io

SCSS
1
star