GithubHelp home page GithubHelp logo

nikbucher / approvaltests.java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from approvals/approvaltests.java

0.0 2.0 0.0 19.81 MB

ApprovalTest verification library for Java

License: Apache License 2.0

Java 99.73% HTML 0.26% Shell 0.01%

approvaltests.java's Introduction

ApprovalTests.Java

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

It is compatible with JUnit 3 & 4 and TestNG

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 .Net scenarios including

  • HashMaps & Collections
  • Long Strings
  • Log Files
  • JPanels
  • Xml
  • Html
  • Json

How to get it

Maven

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

or download the jars from maven central repository

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

Podcasts

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

Download

You can find the latest ApprovalTests release under https://github.com/approvals/ApprovalTests.Java/releases.

Examples

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

None the less, Here's a quick look at some Sample Code

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

Will Produce a File

SampleTest.TestList.received.txt
[0] = Dan
[1] = James
[2] = Jason
[3] = Katrina
[4] = Llewellyn

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

LICENSE

Apache 2.0 License

Questions?

twitter: @LlewellynFalco or #ApprovalTests

Developer notes

We are currently migrating the build from Ant to Maven. To build with Maven:

mvn install

If you see test failures and want to carry on anyway:

mvn install -DskipTests

If you have trouble with the "mrunit" package which is listed on Maven central but doesn't seem to download, install it locally with this command:

mvn install:install-file -Dfile=java/jars/hadoop/mrunit-0.9.0-incubating-hadoop1.jar -DgroupId=org.apache.mrunit -DartifactId=mrunit -Dversion=0.9.0-incubating -Dpackaging=jar

If you want to create the signed jars suitable for release, you will need a gpg key to sign it with. Install gpg (for example with brew install gnupg), and create a key.

Then build with this command:

mvn verify -DperformRelease=true -Dgpg.passphrase=xx

(Replace the xx with the actual passphrase for your key)

Helpful page if you get an error 'Inappropriate ioctl for device'

If you would like to instead build this project with Apache ant, then use these commands:

 ant "Publish    ApprovalTests-Util" -buildfile build/build.xml
 cp approvaltests-util/target/approvaltests-util.jar java/jars/
 ant "Publish    ApprovalTests" -buildfile build/build.xml
 cp approvals/target/ApprovalTests.jar java/jars
 ant "Publish    HtmlLocker" -buildfile build/build.xml
 ant "Publish    CounterDisplay" -buildfile build/build.xml
 ant "Publish    approvaltests-hadoop" -buildfile build/build.xml
 ant "Publish    approvaltests-testng" -buildfile build/build.xml

This will build jar files under the target folder for each respective project. At present you have to copy the built jar files by hand in between ant steps, since the subprojects depned on one another. Soon this will be handled by maven instead.

approvaltests.java's People

Contributors

beatngu13 avatar emilybache avatar isidore avatar martinsson avatar rkalis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.