Giter Club home page Giter Club logo

etap's Introduction

README

etap is a collection of Erlang modules that provide a TAP testing client library. These modules allow developers to create extensive and comprehensive tests covering many aspects of application and module development. This includes simple assertions, exceptions, the application behavior and event web requests. This library was originally written by Jeremy wall.

As per the TAP wiki:

TAP, the Test Anything Protocol, is a simple text-based interface between testing modules in a test harness. TAP started life as part of the test harness for Perl but now has implementations in C/C++, Python, PHP, Perl and probably others by the time you read this.

These modules are not meant to compete with eunit, but to offer a more general testing facility that isn't provided by eunit.

http://en.wikipedia.org/wiki/Test_Anything_Protocol
http://testanything.org

CREATING TESTS

A "test" is any number of etap:* or etap_*:* tests that are part of a test plan. When a plan is created using etap:plan/1, a process is started that tracks the status of the tests executed and handles diagnostic output.

Consider the following example test plan:

etap:plan(3),
etap:ok(true, "the 'true' atom is recognized"),
etap:is(1 + 1, 2, "simple math"),
etap:isnt(2 + 2, 5, "some would argue"),
etap:end_tests().

For tests that require pattern matching, a macro can be used.

-include("etap.hrl").
...
?ETAP_MATCH({foo, bar, baz}, {foo, _, _}, "a three-element tuple with foo as the first element"),

There are a number of utility tests that can be used. The etap:any/3, etap:none/3, etap:fun_is/3, and etap:expect_fun/3 use functions to return either 'true' or 'false'.

Numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9],
FunWithNumbers = fun(X) case X of [1, 2, 3 | _] -> true; _ -> false end end,
etap:fun_is(FunWithNumbers, Numbers, "Match the first three numbers").

There are many examples in t/*.erl.

BUILD & INSTALL

To build this library, from the root directory execute the make command. You should also execute the make test command to verify that the library functions correctly on your system. If you have the Perl module TAP::Harness you can use it to collect and display test results using the make prove target.

$ make
$ make test
$ make prove

If you choose to run the make test command then please be sure to make clean after to remove any of the temporary beam files created by the tests in the t/ directory.

The included tests cover the basic functionality of the etap modules. They can also be used as a reference when writing your own tests.

To install etap you need to create the etap/ebin/ directory in your current Erlang library and copy all of the .beam files created by the make file.

$ sudo mkdir -p /usr/lib/erlang/lib/etap-0.3.4/ebin
$ make clean && make
$ sudo cp ebin/*.beam /usr/lib/erlang/lib/etap-0.3.4/ebin/

The make dist-src target can be used to create source distributions for further packaging and deployment.

USING TAP::Harness

The 'TAP::Harness' library can be used to collect TAP output produced by this module.

$ cpan install TAP::Harness
$ prove t/*.t
$ prove -v t/*.t

TEST COVERAGE

With etap it is possible to test the code coverage of your test suite. To enable code coverage you must set the "COVER" environmental variable and post-compile all of the .coverdata files created by the test suite.

$ COVER=1 erl -eval 'module:test().' -s init stop ...
OR
$ COVER=1 escript t/*.t
OR
$ COVER=1 prove t/*.t
$ erl
1> etap_report:create().
...
ok

There are several assumptions made here:

  • All of the modules you are trying to get coverage for reside in the ./ebin/ directory. If this is not the case, the directory can be set using the "COVER_BIN" environmental variable.
  • All of the .beam files analyzed by this code coverage feature are compiled with the +debug_info flag.

SUPPORTED FUNCTIONALITY

There are a number of proposals listed on the TAP wiki that are not supported by this library. Please be aware of this when creating your tests.

  • LIMITED SUPPORTED: TAP diagnostic syntax
  • LIMITED SUPPORTED: TAP meta information
  • LIMITED SUPPORTED: TAP logging syntax
  • NOT SUPPORTED: TODO
  • SUPPORTED: SKIP
  • SUPPORTED: TAP datetime
  • SUPPORTED: c0 code coverage
  • SUPPORTED: html code coverage reports

We Need Your Help!

Things that can greatly be improved. Please fork this project and contribute. Patches are always welcome.

  • Support for testing multi-node systems and environments.
  • OTP behaviors like gen_server, gen_fsm and gen_event
  • Things like the error_logger and sasl
  • C1 code coverage reporting and html output
  • Documentation

I've got a project. How can I integrate testing?

If you haven't been a test-first developer before, now is the best time to start. To integrate etap into your project, you need to do 3 things.

  1. Install etap onto your development/build/integration system.
  2. Create tests! Start with really simple things like loading modules and gradually build tests into more and more complex and deep functionality.
  3. Run your tests. This is the most important step. Get into the habit of running your test suite before every check-in, after every pull, before packaging, etc.

CREDITS

2008-2009 Nick Gerakines
2007-2008 Jeremy Wall
2008 Jacob Vorreuter

Special thanks to everyone that has contributed to this project.

  • Paul J. Davis
  • Brad Anderson
  • Ken Pratt
  • Kevin Ilchmann Jørgensen
  • Benoit Chesneau
  • Adam Kocoloski
  • Jayson Vantuyl

etap's People

Contributors

benoitc avatar boorad avatar davisp avatar ddossot avatar kenpratt avatar kocolosk avatar lemenkov avatar ngerakines avatar zaphar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

etap's Issues

Support for Sumanjs + etap 4 Erlang

Hi there! I am in the process of writing an agnostic test runner:

https://github.com/sumanjs/suman

Suman is agnostic, it can run anything with a hashbang.
I am not very familiar with Erlang, but I would like to support Erlang.

I have two questions/asks for you!

  1. I don't know Erlang (yet) - one small favor I would like to ask of you - if you could pass me an Erlang script that outputs TAP test results, I would like to include that in the Suman test suite (the test suite for the library itself!). Hope this makes sense.

  2. Do you know of any similar reporters for Erlang (or Go, etc) that are similar to TAP and can be used in the same way? I need to support them too, but I don't know of much besides TAP.

Thanks!

make test fails (on 64b systems)

Hi!
I can't get etap to work on 3 different machines; It doesn't pass its `make test', crashing here:

Running tests for etap_t_011
erl -pa ../ebin -run etap_t_011 start -run init stop -noshell
1..0 # skip
{"init terminating in do_boot",{badarg,[{etap,end_tests,0},{init,start_it,1},{init,start_em,1}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
make[1]: *** [etap_t_011] Error 1
make[1]: Leaving directory `/home/wk/src/etap/t'
make: *** [test] Error 2

Git bisection showed the affected commit is:
commit f5d36d0
Author: Nick Gerakines [email protected]
Date: Fri Apr 24 18:33:42 2009 -0700

Adding support for unknown test plans. Bumped version to 0.3.4

Fallback to previous commit makes it pass.
I don't believe some bug was unnoticed for so long so I guess there may be some locality - all 3 systems are 64b machines, Debian and Ubuntu with R13B01 compiled by hand.

Funny thing is that I don't have access to any 32b erlang right now so I can't investigate it more. It may be that you and most users have the opposite setting.

cheers,
Wojtek

bootstrap broken

While trying to create make file :

./bootstrap
./configure && make

I get following error

make[2]: *** No rule to make target overview.edoc', needed by.run_edoc'. Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
enlil:etap benoitc$ ls

Also it seems that build process is different from the one in README or did I missed something ?

Is etap_can missing?

Hi!

When I run make test it fails on etap_t_002.

Running tests for etap_t_002
erl -pa ../ebin -run etap_t_002 start -run init stop -noshell
{"init terminating in do_boot",{undef,[{etap_can,loaded_ok,[etap,"module 'etap' loaded"]},{etap_t_002,test_etap,0},{etap_t_002,start,0},{init,start_it,1},{init,start_em,1}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
make[1]: *** [etap_t_002] Error 1
make[1]: Leaving directory `/home/per/src/github/etap/t'
make: *** [test] Error 2

I can't seem to find etap_can anywhere in this repo, is it missing?

The same goes for etap_exception, etap_process, etap_application, etap_web, etap_request. Are they missing?

Best,
Per

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.