microtest alternatives and similar shards
Based on the "Testing" category.
Alternatively, view microtest alternatives based on common mentions on social networks and blogs.
-
spec2-mocks
This library connects spec2.cr and mocks.cr, effectively enabling 'have_received' expectation for spec2. -
hashr
Hashr is a tiny library makes test on JSON response easier, and can also be used as a models object.
SaaSHub - Software Alternatives and Reviews
Do you think we are missing an alternative of microtest or a related project?
Popular Comparisons
README
microtest
Version 1.2.3
A very tiny testing framework inspired by minitest/minitest.cr.
Features
- This framework is opinionated
- It uses power asserts by default. There are no
assert_equals
,assert_xyz
, just power asserts (except forassert_raises
) - It uses the spec syntax for test case structure (
describe
,test
,before
,after
). Reasons: No test-case name-clashes when using describe. Not forgetting to call super in setup/teardown methods. - No nesting of describe blocks. IMO nesting of those blocks is an anti-pattern.
- No let-definitions. Only before / after hooks. Use local variables mostly.
- Tests have to be started explicitly by
Microtest.run!
, no at-exit hook. - Colorized and abbreviated exception stacktraces
Installation
Add this to your application's shard.yml
:
development_dependencies:
microtest:
github: ragmaanir/microtest
version: ~> 1.2.3
And add this to your spec_helper.rb
:
require "microtest"
include Microtest::DSL
Microtest.run!
Usage
describe MyLib::WaterPump do
test "that it pumps water" do
p = MyLib::WaterPump.new("main")
p.enable
p.start
assert(p.pumps_water?)
end
test "that it pumps with a certain speed" do
p = MyLib::WaterPump.new("main", speed: 100)
p.enable
p.start
assert(p.pump_speed > 50)
end
test "this one is pending since it got no body"
test "only run this focused test", :focus do
end
test! "and this one too since it is focused also" do
end
end
Run the test with:
crystal spec
You can provide the seed to run the tests in the same order:
SEED=123 crystal spec
Power Assert Output
describe AssertionFailure do
test "assertion failure" do
a = 5
b = "aaaaaa"
assert "a" * a == b
end
end
Generates:
[Assertion Failure](assets/assertion_failure.jpg?raw=true)
Microtest Test Output (default reporter)
[Default](assets/spec.jpg?raw=true)
Reporters
Select the used reporters:
Microtest.run!([
Microtest::DescriptionReporter.new,
Microtest::ErrorListReporter.new,
Microtest::SlowTestsReporter.new,
Microtest::SummaryReporter.new,
] of Microtest::Reporter)
describe First do
test "success" do
end
test "skip this"
end
describe Second do
def raise_an_error
raise "Oh, this is wrong"
end
test "first failure" do
a = 5
b = 7
assert a == b * 2
end
test "error" do
raise_an_error
end
end
Progress Reporter
[Progress Reporter](assets/progress_reporter.jpg?raw=true)
Description Reporter
[Description Reporter](assets/description_reporter.jpg?raw=true)
When focus active
describe Focus do
test "not focused" do
end
test! "focused" do
end
test "focused too", :focus do
end
end
[Focus](assets/focus.jpg?raw=true)
Development
I am using guardian to run the tests on each change. Also the guardian task uses the computer voice to report build/test failure/success.
Run bin/build
to run tests and generate README.md
from README.md.template
and generate the images of the test outputs (using an alpine docker image).
DONE
- [x] hooks (before, after, around), and global ones for e.g. global transactional fixtures
- [x] Customizable reporters
- [x] Capture timing info
- [x] Randomization + configurable seed
- [x] Reporter: list N slowest tests
- [x] assert_raises
- [x] skip
- [x] Write real tests for Microtest (uses JSON report to check for correct test output). Now tests are green.
- [x] JSON reporter
- [x] SummaryRepoter
- [x] Continuous Integration with Travis
- [x] focus
- [x] generate README including examples from specs and terminal screenshots
- [x] Print whether focus is active
- [x] crtl+c to halt tests
TODO
- [ ] fail fast
- [ ] Number of assertions
- [ ] Alternatives to nesting? (Use separate describe blocks)
- [ ] Group tests and specify hooks and helper methods for the group only
- [ ] save results to file and compare current results to last results, including timings
Problems
- [ ] Some assertion failures cause segfaults