• This repository has been archived on 10/Jan/2020
  • Stars
    star
    217
  • Rank 176,819 (Top 4 %)
  • Language
    Common Lisp
  • Created over 13 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

Yet another unit testing framework for Common Lisp

prove

This project was originally called 'CL-TEST-MORE'.

'prove' is yet another unit testing framework for Common Lisp.

The advantages of 'prove' are:

Quickstart

1. Writing a test file

(in-package :cl-user)
(defpackage my-test
  (:use :cl
        :prove))
(in-package :my-test)

(plan 3)

(ok (not (find 4 '(1 2 3))))
(is 4 4)
(isnt 1 #\1)

(finalize)

2. Run a test file

(prove:run #P"myapp/tests/my-test.lisp")
(prove:run #P"myapp/tests/my-test.lisp" :reporter :list)

See also: ASDF integration, Reporters

3. Get a report

Installation

You can install 'prove' via Quicklisp.

(ql:quickload :prove)

Testing functions

(ok test &optional desc)

Checks if test is true (non-NIL).

(ok 1)
;->  โœ“ 1 is expected to be T

(is got expected &rest test-args)

Checks if got is equivalent to expected.

(is 1 1)
;->  โœ“ 1 is expected to be 1

(is #(1 2 3) #(1 2 3))
;->  ร— #(1 2 3) is expected to be #(1 2 3)

(is #(1 2 3) #(1 2 3) :test #'equalp)
;->  โœ“ #(1 2 3) is expected to be #(1 2 3)

;; with description
(is 1 #\1 "Integer = Character ?")
;->  ร— Integer = Character ?

(isnt got expected &rest test-args)

Checks if got is not equivalent to expected.

(isnt 1 1)
;->  ร— 1 is not expected to be 1

(isnt #(1 2 3) #(1 2 3))
;->  โœ“ #(1 2 3) is not expected to be #(1 2 3)

(is-values got expected &rest test-args)

Checks if the multiple values of got is equivalent to expected. This is same to (is (multiple-value-list got) expected).

(defvar *person* (make-hash-table))

(is-values (gethash :name *person*) '("Eitaro" T))
;->  ร— (NIL NIL) is expected to be ("Eitaro" T)

(setf (gethash :name *person*) "Eitaro")

(is-values (gethash :name *person*) '("Eitaro" T))
;->  โœ“ ("Eitaro" T) is expected to be ("Eitaro" T)

(is-type got expected-type &optional desc)

Checks if got is a type of expected-type.

(is-type #(1 2 3) 'simple-vector)
;->  โœ“ #(1 2 3) is expected to be a type of SIMPLE-VECTOR (got (SIMPLE-VECTOR 3))

(is-type (make-array 0 :adjustable t) 'simple-vector)
;->  ร— #() is expected to be a type of SIMPLE-VECTOR (got (VECTOR T 0))

(like got regex &optional desc)

Checks if got matches a regular expression regex.

(like "Hatsune 39" "\\d")
;->  โœ“ "Hatsune 39" is expected to be like "\\d"

(like "ๅˆ้ŸณใƒŸใ‚ฏ" "\\d")
;->  ร— "ๅˆ้ŸณใƒŸใ‚ฏ" is expected to be like "\\d"

(is-print got expected &optional desc)

Checks if got outputs expected to *standard-output*

(is-print (princ "Hi, there") "Hi, there")
;->  โœ“ (PRINC "Hi, there") is expected to output "Hi, there" (got "Hi, there")

(is-error form condition &optional desc)

Checks if form raises a condition and that is a subtype of condition.

(is-error (error "Something wrong") 'simple-error)
;->  โœ“ (ERROR "Something wrong") is expected to raise a condition SIMPLE-ERROR (got #<SIMPLE-ERROR "Something wrong" {100628FE53}>)

(define-condition my-error (simple-error) ())

(is-error (error "Something wrong") 'my-error)
;->  ร— (ERROR "Something wrong") is expected to raise a condition MY-ERROR (got #<SIMPLE-ERROR "Something wrong" {100648E553}>)

(is-expand got expected &optional desc)

Checks if got will be macroexpanded to expected.

(is-expand (when T (princ "Hi")) (if T (progn (princ "Hi"))))
;->  โœ“ (WHEN T (PRINC "Hi")) is expected to be expanded to (IF T
;                                                          (PROGN (PRINC "Hi"))) (got (IF T
;                                                                                         (PROGN
;                                                                                          (PRINC
;                                                                                           "Hi"))
;                                                                                         NIL))

If a symbol that starts with "$" is contained, it will be treated as a gensym.

(pass desc)

This will always be passed. This is convenient if the test case is complicated and hard to test with ok.

(pass "Looks good")
;->  โœ“ Looks good

(fail desc)

This will always be failed. This is convenient if the test case is complicated and hard to test with ok.

(fail "Hopeless")
;->  ร— Hopeless

(skip how-many why)

Skip a number of how-many tests and mark them passed.

(skip 3 "No need to test these on Mac OS X")
;->  โœ“ No need to test these on Mac OS X (Skipped)
;    โœ“ No need to test these on Mac OS X (Skipped)
;    โœ“ No need to test these on Mac OS X (Skipped)

(subtest desc &body body)

Run tests of body in a new sub test suite.

(subtest "Testing integers"
  (is 1 1)
  (is-type 1 'bit)
  (is-type 10 'fixnum))
;->      โœ“ 1 is expected to be 1
;        โœ“ 1 is expected to be a type of BIT (got BIT)
;        โœ“ 10 is expected to be a type of FIXNUM (got (INTEGER 0 4611686018427387903))
;->  โœ“ Testing integers

Other functions

(diag desc)

Outputs desc to a *test-result-output*.

(diag "Gonna run tests")
;-> # Gonna run tests

(plan num)

Declares a number of num tests are going to run. If finalize is called with no plan, a warning message will be output. num is allows to be NIL if you have no plan yet.

(finalize)

Finalizes the current test suite and outputs the test reports.

(slow-threshold milliseconds)

Set the threshold of slow test durations for the current test suite. The default threshold value is prove:*default-slow-threshold*.

(slow-threshold 150)

Reporters

You can change the test report formats by setting prove:*default-reporter* to :list, :dot, :tap or :fiveam. The default value is :list.

prove:run also takes a keyword argument :reporter.

List (Default)

The :list repoter outputs test results list as test cases pass or fail.

Dot

The :dot reporter outputs a series of dots that represent test cases, failures highlight in red, skipping in cyan.

FiveAM

The :fiveam reporter outputs test results like FiveAM does.

TAP

The :tap reporter outputs in Test Anything Protocol format.

Tips

Debugging with CL debugger

Set prove:*debug-on-error* T for invoking CL debugger whenever getting an error during running tests.

Colorize test reports on SLIME

SLIME doesn't support to color with ANSI colors in the REPL buffer officially.

You can add the feature by using slime-repl-ansi-color.el.

After installing it, set prove:*enable-colors* to T before running tests.

;; A part of my ~/.sbclrc
(ql:quickload :prove)
(setf prove:*enable-colors* t)

The following snippet is a little bit complicated, however it would be better if you don't like to load prove in all sessions.

(defmethod asdf:perform :after ((op asdf:load-op) (c (eql (asdf:find-system :prove))))
  (setf (symbol-value (intern (string :*enable-colors*) :prove)) t))

ASDF integration

Add :defsystem-depends-on (:prove-asdf) to your testing ASDF system to enable :test-file in the :components.

:test-file is same as :file except it will be loaded only when asdf:test-system.

;; Main ASDF system
(defsystem my-app

  ;; ...

  :in-order-to ((test-op (test-op my-app-test))))

;; Testing ASDF system
(defsystem my-app-test
  :depends-on (:my-app
               :prove)
  :defsystem-depends-on (:prove-asdf)
  :components
  ((:test-file "my-app"))
  :perform (test-op :after (op c)
                    (funcall (intern #.(string :run) :prove) c)))

To run tests, execute asdf:test-system or prove:run in your REPL.

(asdf:test-system :my-app)
(asdf:test-system :my-app-test)

;; Same as 'asdf:test-system' except it returns T or NIL as the result of tests.
(prove:run :my-app-test)

Changing default test function

Test functions like is uses prove:*default-test-function* for testing if no :test argument is specified. The default value is #'equal.

Changing output stream

Test reports will be output to prove:*test-result-output*. The default value is T, which means *standard-output*.

Running tests on Travis CI

Although Common Lisp isn't supported by Travis CI officially, you can run tests by using cl-travis.

Here's a list of .travis.yml from projects using prove on Travis CI:

Bugs

Please report any bugs to [email protected], or post an issue to GitHub.

License

Copyright (c) 2010-2014 Eitaro Fukamachi <[email protected]>
'prove' and CL-TEST-MORE is freely distributable under the MIT License (http://www.opensource.org/licenses/mit-license).

More Repositories

1

woo

A fast non-blocking HTTP server on top of libev
Common Lisp
1,255
star
2

clack

Web server abstraction layer for Common Lisp
Common Lisp
1,021
star
3

caveman

Lightweight web application framework for Common Lisp.
Common Lisp
769
star
4

qlot

A project-local library installer for Common Lisp
Common Lisp
384
star
5

dexador

A fast HTTP client for Common Lisp
Common Lisp
358
star
6

sxql

An SQL generator for Common Lisp.
Common Lisp
349
star
7

fast-http

A fast HTTP request/response parser for Common Lisp.
Common Lisp
338
star
8

mito

An ORM for Common Lisp with migrations, relationships and PostgreSQL support
Common Lisp
270
star
9

ningle

Super micro framework for Common Lisp
Common Lisp
254
star
10

cl-project

Generate modern project skeletons
Common Lisp
234
star
11

cl-dbi

Database independent interface for Common Lisp
Common Lisp
195
star
12

rove

#1=(yet another . #1#) common lisp testing library
Common Lisp
139
star
13

lack

Lack, the core of Clack
Common Lisp
137
star
14

quri

Yet another URI library for Common Lisp
Common Lisp
105
star
15

websocket-driver

WebSocket server/client implementation for Common Lisp
Common Lisp
101
star
16

datafly

A lightweight database library for Common Lisp.
Common Lisp
97
star
17

utopian

A web framework for Common Lisp never finished.
Common Lisp
95
star
18

lsx

Embeddable HTML templating engine for Common Lisp with JSX-like syntax
Common Lisp
78
star
19

shelly

[OBSOLETE] Use Roswell instead.
Common Lisp
63
star
20

envy

Configuration switcher by an environment variable inspired by Config::ENV.
Common Lisp
57
star
21

integral

[OBSOLETE] Use Mito instead.
Common Lisp
54
star
22

mondo

Simple Common Lisp REPL
Common Lisp
52
star
23

psychiq

Background job processing for Common Lisp
Common Lisp
51
star
24

getac

Quick unit testing tool for competitive programming
Common Lisp
46
star
25

dockerfiles

Dockerfiles for Common Lisp programming
Shell
40
star
26

proc-parse

Procedural vector parser
Common Lisp
36
star
27

jose

A JOSE implementation
Common Lisp
32
star
28

redmine-el

See Redmine on Emacs
Emacs Lisp
30
star
29

legion

Simple multithreading worker mechanism.
Common Lisp
30
star
30

cl-coveralls

Common Lisp
29
star
31

docker-cl-example

Example projects to run/develop Common Lisp web application on Docker container
Common Lisp
28
star
32

L5

Yet Another Presentation Tool for Lispers
Clojure
28
star
33

event-emitter

Event mechanism for Common Lisp objects.
Common Lisp
28
star
34

.lem

Lem configuration files
Common Lisp
27
star
35

assoc-utils

Utilities for manipulating association lists.
Common Lisp
25
star
36

clozure-cl

Unofficial mirror of Clozure CL
Common Lisp
25
star
37

supertrace

Superior Common Lisp `trace` functionality for debugging/profiling real world applications.
Common Lisp
25
star
38

myway

Sinatra-compatible URL routing library for Common Lisp
Common Lisp
24
star
39

fast-websocket

Optimized low-level WebSocket protocol parser written in Common Lisp
Common Lisp
22
star
40

uncl

Un-Common Lisp on Common Lisp
Common Lisp
22
star
41

cl-locale

Simple i18n library for Common Lisp
Common Lisp
21
star
42

ragno

Common Lisp Web crawling library based on Psychiq.
Common Lisp
19
star
43

safety-params

Check params
Common Lisp
19
star
44

anypool

General-purpose connection pooling library for Common Lisp
Common Lisp
19
star
45

mito-auth

User authorization for Mito classes.
Common Lisp
18
star
46

cl-cookie

HTTP cookie manager
Common Lisp
18
star
47

xsubseq

Efficient way to use "subseq"s in Common Lisp
Common Lisp
16
star
48

smart-buffer

Smart octets buffer.
Common Lisp
16
star
49

http-body

HTTP POST data parser.
Common Lisp
15
star
50

re21

CL21's spin-off project that provides neat APIs for regular expressions.
Common Lisp
15
star
51

webapi

CLOS-based wrapper builder for Web APIs.
Common Lisp
15
star
52

lev

libev bindings for Common Lisp
Common Lisp
15
star
53

.emacs.d

My .emacs.d
Emacs Lisp
15
star
54

lesque

[OBSOLETE] Use Psychiq instead.
Common Lisp
14
star
55

pem

PEM parser.
Common Lisp
14
star
56

circular-streams

Circularly readable streams for Common Lisp.
Common Lisp
14
star
57

mito-attachment

Mito mixin class for file management outside of RDBMS
Common Lisp
14
star
58

emacs-config

[OBSOLETE] More simplified version is
Emacs Lisp
13
star
59

yapool

A Common Lisp command-line tool for executing shell commands via SSH.
12
star
60

cl-line-bot-sdk

SDK for the LINE Messaging API for Common Lisp
Common Lisp
11
star
61

id3v2

ID3v2 parser
Common Lisp
10
star
62

kindly-mode

Amazon Kindle-like view mode for Emacs.
Emacs Lisp
10
star
63

wsock

Low-level UNIX socket library
Common Lisp
9
star
64

asn1

ASN.1 decoder
Common Lisp
9
star
65

can

A role-based access right control library.
Common Lisp
8
star
66

hatenablog-theme-writer

็‰ฉๆ›ธใใฎใŸใ‚ใฎใƒ–ใƒญใ‚ฐใƒ†ใƒผใƒžใ€ŒWriterใ€ for ใฏใฆใชใƒ–ใƒญใ‚ฐ
CSS
7
star
67

neovim-config

~/.config/nvim
Vim Script
7
star
68

clee

Common Lisp Event Engine
Common Lisp
6
star
69

fukacl

Fukamachi Common Lisp Package
Common Lisp
6
star
70

ponzu.db

O/R Mapper, a part of Ponzu Framework, for Common Lisp
Common Lisp
6
star
71

gotanda

Common Lisp
6
star
72

clbuild

Unofficial fork of clbuild
Shell
5
star
73

mp3-duration

Get the duration of an MP3 file
Common Lisp
5
star
74

asdf-c-test-file

Provides ASDF component :test-file.
Common Lisp
5
star
75

sxql-abstract

An abstraction layer for SQL between RDBMS.
Common Lisp
5
star
76

as-interval

An extension of cl-async for introducing 'interval' feature.
Common Lisp
5
star
77

fukamachi.github.com

HTML
4
star
78

p5-shelly

[DEPRECATED] Moved to https://github.com/fukamachi/shelly
Perl
4
star
79

github-webhook

Docker container to listen for GitHub webhook events
Common Lisp
4
star
80

dont-type-twice-el

Supports your effective text editing.
Emacs Lisp
4
star
81

nail

Common Lisp
4
star
82

lem-vi-sexp

vim-sexp port for Lem
Common Lisp
4
star
83

multival-plist

Property List stores multiple values per one key.
Common Lisp
4
star
84

kunitada-bot

All tweets should be "fastest".
Ruby
3
star
85

trivial-utf-8

Imported from the original darcs repo.
Common Lisp
3
star
86

closure-library-skeleton

Skeleton files for a project using Google Closure Library.
JavaScript
3
star
87

clack-doc

[DEPRECATED] Documentation tool for Clack (I moved them to Quickdocs.org)
Common Lisp
3
star
88

ac-swift

Swift auto completion for Emacs
Emacs Lisp
3
star
89

gotumda

Put all your tasks into one bucket.
JavaScript
3
star
90

opImKayacComPlugin

PHP
2
star
91

partial-bench

A tiny benchmarking library to get a running time of a specific part.
Common Lisp
2
star
92

p5-gotumda

Communicate over tasks.
JavaScript
2
star
93

swank.ros

Common Lisp
2
star
94

Plack-Middleware-Try

Plack Middleware to catch exceptions.
Perl
2
star
95

Plack-Middleware-StackTraceLog

Plack Middleware for logging when your app dies.
Perl
1
star
96

cl-weather-jp

Get weather in Japan
Common Lisp
1
star
97

rove-test-example

Common Lisp
1
star