Code Monkey home page Code Monkey logo

test-more's Introduction

EL-TEST-MORE - Emacs test frameworket like Perl's Test::More

EL-TEST-MORE is inspired by Perl's Test::More and Common Lisp's CL-TEST-MORE.

EL-TEST-MORE support TAP(Test Anything Protocol), so that you can test elisp by prove command.

Synopsis

(require 'test-more)
(test-more:import)

(plan 3)

(ok (typep "test-more" 'string) "string type test")
(is (+ 1 1) 2 "add test")

(like "987" "^[0-9]+$")

;; Don't forget this
(finalize)

Test Functions

  • test-more:plan($num)

Plan to test $num tests. You should call test-more:plan at first.

  • test-more:finalize

Finalize this test file. You should call test-more:finalize at last.

  • test-more:ok($got [$desc])

Test $got is true.

  • test-more:is($got $expected [$desc])

Test $got equals to $expected. default test function is equal.

  • test-more:isnt

Test $got does not equals to $expected. default test function is equal.

  • test-more:diag($diag)

Output $diag as diagnostics

  • test-more:is-type($got $type [$desc])

Test type of $got is $type.

  • test-more:like($got $regexp [$desc])

Test $regexp matchs $got.

  • test-more:skip($why $how-many)

Skip $how-many tests.

  • test-more:pass($desc)

Always pass.

  • test-more:fail($desc)

Always failed.

Test Macros

  • test-more:is-print($form $expected [$desc])

Test output of $form to STDOUT equals to $expected

  • test-more:is-error($form [$desc])

Test $form throws exception.

  • test-more:todo($desc $forms)

Like Perl Test::More TODO block. test-more:todo is the mark that means tests in it will be implemented.

  • test-more:subtest(desc $forms)

Like Perl Test::More subtest. Group similar tests. Tests in test-more:subtest is treated one test.

  • test-more:done-testing($forms)

Like Perl Test::More done-testing.

Call Test Functions without test-more:prefix

You call (test-more:import) at first.

Support TAP(Test Anything Protocol)

EL-TEST-MORE supports TAP(Test Anything Protocol). You evaluate following elisp

(require 'test-more)
(test-more:import)

(plan 4)

(ok (typep "This is String" 'string) "first argument is true")

(is '(a b) '(a b) "first argument equals to second argument")
(like "987" "^[0-9]+$" "first argument matchs second argument which is regexp")

(fail "Failing test")

(finalize)

You get following output

1..4
ok 1 - first argument is true
ok 2 - first argument equals to second argument
ok 3 - first argument matchs second argument which is regexp
not ok 4 - Failing test
#  Looks like you failed 1 tests of 4 run

Run test with prove

You can test elisp file with following prove command

prove -v --exec='emacs -Q --batch -l test-more.el -l' test_files

To write .proverc makes you test easily.

--exec "emacs -Q --batch -L ~/.emacs.d/auto-install -l test-more.el -l"
--color
--merge
--timer
-w

and you can use following command for testing

prove -v test_files

test-more's People

Contributors

syohex 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.