All Projects → emancu → crotest

emancu / crotest

Licence: MIT License
A tiny and simple test framework for crystal

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to crotest

Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. The most up to date documentation can be found on Cucumber.Pro (https://app.cucumber.pro/projects/aruba)
Stars: ✭ 900 (+3650%)
Mutual labels:  test-driven-development, testing-framework
iutest
c++ testing framework
Stars: ✭ 58 (+141.67%)
Mutual labels:  assertions, testing-framework
Awesome Unit Testing Swift
A curated collection of awesome blog articles, books, talks, podcasts, tools/frameworks and examples.
Stars: ✭ 272 (+1033.33%)
Mutual labels:  test-driven-development, testing-framework
polish
Testing Framework for Rust
Stars: ✭ 44 (+83.33%)
Mutual labels:  test-driven-development, testing-framework
tau
A Micro (1k lines of code) Unit Test Framework for C/C++
Stars: ✭ 121 (+404.17%)
Mutual labels:  assertions, testing-framework
Bash unit
bash unit testing enterprise edition framework for professionals
Stars: ✭ 419 (+1645.83%)
Mutual labels:  assertions, test-driven-development
Bandit
Human-friendly unit testing for C++11
Stars: ✭ 240 (+900%)
Mutual labels:  test-driven-development, testing-framework
PixelTest
Fast, modern, simple iOS snapshot testing written purely in Swift.
Stars: ✭ 56 (+133.33%)
Mutual labels:  test-driven-development, testing-framework
Tf
✔️ tf is a microframework for parameterized testing of functions and HTTP in Go.
Stars: ✭ 133 (+454.17%)
Mutual labels:  assertions, testing-framework
Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+22804.17%)
Mutual labels:  assertions, testing-framework
eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (+70.83%)
Mutual labels:  test-driven-development, testing-framework
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+26500%)
Mutual labels:  assertions, testing-framework
kheera-testrunner-android
BDD Framework for Android
Stars: ✭ 18 (-25%)
Mutual labels:  testing-framework
praetorian
A minimalist Crystal authorization system inspired by https://github.com/varvet/pundit.
Stars: ✭ 54 (+125%)
Mutual labels:  crystal-lang
form builder.cr
Dead simple HTML form builder for Crystal with built-in support for many popular UI libraries such as Bootstrap
Stars: ✭ 29 (+20.83%)
Mutual labels:  crystal-lang
CloudRaider
A resiliency tool that automates Failure mode effect analysis tests, simplifying complex testing with a behavior-driven development and testing approach. Provides a programmatic way to execute controlled failures in AWS and a BDD way to write test cases, allowing test plans themselves to become test cases that can be executed as is.
Stars: ✭ 26 (+8.33%)
Mutual labels:  testing-framework
deckard
DNS test harness
Stars: ✭ 28 (+16.67%)
Mutual labels:  testing-framework
flake8-aaa
A Flake8 plugin that checks Python tests follow the Arrange-Act-Assert pattern
Stars: ✭ 51 (+112.5%)
Mutual labels:  test-driven-development
tdiff
CLI tool for comparing tree like structures
Stars: ✭ 20 (-16.67%)
Mutual labels:  crystal-lang
upssert
Simple REST API assertion framework
Stars: ✭ 13 (-45.83%)
Mutual labels:  assertions

crotest

Build

A tiny and simple test framework for Crystal with common assertions and no pollution into Object class.

Example

require "crotest"

describe "DSL" do
  it "defines small test cases" do
    assert true
  end

  describe "nested describes for a better readability" do
    it "has only a few assertions" do
      var = false

      reject var
      assert_equal false, var
      assert_raise Exception do
        raise Exception.new("Boom!")
      end
    end
  end

  pending "tests are defined without a block"

  pending "tests can also be defined with a block, which will not be executed" do
    fail "This won't be executed :)"
  end
end

Installation

Add this to your application's shard.yml:

dependencies:
  crotest:
    github: emancu/crotest

Usage

require "crotest"

Run your tests with crystal spec.

Assertions

  • assert
  • reject
  • assert_equal
  • assert_raise

Custom assertions

Extend the assertions used by Crotest is really easy. You need to open the module Crotest::Assertions and add your assertions like the example below:

require "crotest"

module Crotest::Assertions
  macro assert_greater_than_4(value, file = __FILE__, line = __LINE__)
    assert {{value}} > 4, "#{{{value}}} <= 4", {{file}}, {{line}}
  end
end


it "supports my custom assertion" do
  assert_greater_than_4 5
end

Before/After blocks

If you need to run code before or after each test, declare each block like in the example below. Remember to define before/after blocks before the corresponding it blocks. Given this is not dynamically evaluated, we must define at the beginning of the file or describe block.

before do
  # First block to be executed
end

after do
  # Fifth and last block to be executed
end

describe "a nested context" do
  before do
    # Second block to be executed
  end

  after do
    # Fourth block to be executed
  end

  it "executes the before blocks and" do
    # Third block to be executed
  end
end

Contributing

  1. Fork it ( https://github.com/emancu/crotest/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • emancu Emiliano Mancuso - creator, maintainer
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].