Code Monkey home page Code Monkey logo

test-more-bash's Introduction

Name

Test::More - TAP Testing for Bash

test-more-bash

Synopsis

Write a test file like this. Maybe call it test/test.t:

#!/usr/bin/env bash

TEST_MORE_PATH="/path/to/test-more-bash"
BASHLIB="`
    find $TEST_MORE_PATH -type d |
    grep -E '/(bin|lib)$' |
    xargs -n1 printf "%s:"`"
PATH="$BASHLIB$PATH"

source bash+ :std

use Test::More

plan tests 8

some-command
ok $? 'some-command is ok'

# or:
ok "`some-command`" 'some-command is ok'

pass 'This will always pass'

fail 'This will always fail'

is `echo foo` 'foo' 'foo is foo'

isnt foo bar "foo isn't bar"

like food foo 'food is like foo'

unlike team I "There's no 'I' in 'team'"

diag "A message for stderr"

note "A message for stdout"

output=( $(ls) )
expected=(README lib bin)
cmp-array output expected "list files"

Run the test with prove like this:

prove test/test.t

Prove knows it's Bash from the first line (the hashbang), and it just works.

Description

Test::More is the tried and true testing library for Perl. It uses TAP (the Test Anything Protocol). This is the same thing for Bash. For the most part it should work exactly the same.

Methods

This is the basic usage:

  • plan tests $count

  • ok $status_code "$label"

  • pass "$label"

  • fail "$label"

  • is "$got" "$want" "label"

  • isnt "$got" "$unwanted" "$label"

  • like "$got" "$regex" "$label"

  • unlike "$got" "$regex" "$label"

  • diag "$message"

  • note "$message"

  • done_testing $count

  • plan skip_all "$reason"

  • BAIL_OUT "$reason"

  • `cmp-array output expected "message"

More detailed info coming soon.

Author

Ingy döt Net <[email protected]>

Copyright & License

Copyright 2013-2020. Ingy döt Net.

The MIT License (MIT)

test-more-bash's People

Contributors

admorgan avatar ingydotnet avatar perlpunk avatar

Watchers

 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.