crotest
Version, currently 0.0.210 versions
github.com/emancu/crotest
A tiny and simple test framework for Crystal with common assertions and no pollution into Object class.
Nothing has been indexed for 0.0.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
crotest:
github: emancu/crotest
version: ~> 0.0.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.0.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
crotest
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
assertrejectassert_equalassert_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
- Fork it ( https://github.com/emancu/crotest/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- emancu Emiliano Mancuso - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.0.2- Tagged
- Jan 10, 2022
- Commit
63f191e1df07- Indexed
- not yet
Dependents
Repository
github.com/emancu/crotest
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 24, 2026
- Synced
- Sep 24, 2026
- Versions
- 10