All Projects → zombieleet → Testify

zombieleet / Testify

A unit testing framework written in bash for bash scripts

Programming Languages

shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Testify

unittest expander
A library that provides flexible and easy-to-use tools to parameterize Python unit tests, especially those based on unittest.TestCase.
Stars: ✭ 12 (-73.33%)
Mutual labels:  test, unittest, unit-test
qiniutest
Qiniu httptest tool: qiniutest
Stars: ✭ 36 (-20%)
Mutual labels:  test, unit-test
Capture Stream
Capture stream output.
Stars: ✭ 10 (-77.78%)
Mutual labels:  test, unittest
fake-sftp-server-rule
A JUnit rule that runs an in-memory SFTP server.
Stars: ✭ 34 (-24.44%)
Mutual labels:  test, unittest
got
An enjoyable golang test framework.
Stars: ✭ 234 (+420%)
Mutual labels:  test, assert
pytest-spark
pytest plugin to run the tests with support of pyspark
Stars: ✭ 65 (+44.44%)
Mutual labels:  unittest, unit-test
tsioc
AOP, Ioc container, Boot framework, unit testing framework , activities workflow framework.
Stars: ✭ 15 (-66.67%)
Mutual labels:  unittest, unit-test
VCore
VCore is a Swift collection containing objects, functions, and extensions that I use for my projects
Stars: ✭ 32 (-28.89%)
Mutual labels:  unittest, unit-test
Goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report.
Stars: ✭ 2,943 (+6440%)
Mutual labels:  test, unit-test
Entwine
Testing tools and utilities for Apple's Combine framework.
Stars: ✭ 306 (+580%)
Mutual labels:  test, unit-test
Strikt
An assertion library for Kotlin
Stars: ✭ 310 (+588.89%)
Mutual labels:  test, assert
Nunit cshaprp cheatsheet
Example implementations of each attribute available in Nunit2 unit Testing Framework using C# .NET.
Stars: ✭ 14 (-68.89%)
Mutual labels:  unittest, unit-test
Httptest
Qiniu httptest utilities
Stars: ✭ 571 (+1168.89%)
Mutual labels:  test, unit-test
local-data-api
Data API for local, you can write unittest for AWS Aurora Serverless's Data API
Stars: ✭ 99 (+120%)
Mutual labels:  test, unittest
TestIt
Generate unit testing boilerplate from kotlin files.
Stars: ✭ 32 (-28.89%)
Mutual labels:  unittest, unit-test
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (-55.56%)
Mutual labels:  test, unittest
assert
Go 语言 assert 断言函数
Stars: ✭ 17 (-62.22%)
Mutual labels:  test, assert
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report.
Stars: ✭ 3,019 (+6608.89%)
Mutual labels:  test, unit-test
robot-testing-framework
Robot Testing Framework (RTF)
Stars: ✭ 12 (-73.33%)
Mutual labels:  test, unit-test
Testfx
MSTest V2 framework and adapter
Stars: ✭ 391 (+768.89%)
Mutual labels:  test, unittest

bash-assert

testify is a lightweight unit testing framework for bash

Usage

clone this repository git clone https://github.com/zombieleet/testify.git

create a test file then source testify.bash and the script you want to test in the test file

	# myscript.bash
	function Name() {
		fName="$1"
		lName="$2"

		if [[ -z "$fName" ]];then
			return 5
		fi
	
		if [[ -z "$lName" ]];then
			return 3
		fi

		echo "$fName $lName"
		return 0
	}


	# test.bash
	source ./myscript.bash
	source ./testify.bash
	assert expect "$(Name 'Jane' 'Doe')" "John Doe" "Test for Name Function" "should fail"
	assert expect "$(Name 'Jane' 'Doe')" "Jane Doe" "Test for Name Function" "should succeed"
	assert status "Name" "5" "Test for status code" "should return 5"
	assert status "Name 'Jane' 'Doe'" "0" "Test for Status Code" "should return 0"
	assert status "Name 'Jane' " "3" "Test for Status Code" "should return 3"
	assert status "Name 'Jane' 'Doe'" "12" "Test for Status Code" "it should fail"
	assert regex "$(Name 'Jane' 'Doe')" "Jane" "Test for Regexp" "it should match"
	assert regex "123victory" "\W" "Test for Regexp Non Word Character" "it should fail if match failes"
	assert done


	

Commands

all subcommands to the assert functions requres 4 arguments, the first argument is the actual value to test for, while the second argument is the expected value, the thrid argument is a description of the test , while the fourth argument is a short description of what the test output should be

expect Compares two values

`assert expect "$(Name 'Jane' 'Doe')" "John Doe" "Test for Name Function" "should fail"`

To test the output of a function you have to use command substitution

You can also test single values

`assert expect "victory" "favour" "Test for Name comparison" "This should fail"`

testing for mathematical expressions

`assert expect "$((2+2))" "4" "Test for Simple Math Operation" "It should succeed"`

regex Does a regular expression match. The second argument to this subcommand should be a regular expression

`assert regex "What is the difference between 6 and half a dozen" "[[:digit:]]" "Match Number Regular Expression" "It should succeed"`

status Test for any status code. The second argument should be the expected status code. The first argument to this subcommand should be a command name, and it should not be passed as a command substitution but it should be passed as just a string wrapped in double quotes. The arguments to the function should also be in the double quotes. Arguments with spaced should be wrapped in single quotes

`assert status "ls ." "0" "List in current dir" "it should return 0"`

done This should be last subcommand to call, it does not require any argument

LICENSE

GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].