Test Tube alternatives and similar gems
Based on the "Testing" category.
Alternatively, view test_tube alternatives based on common mentions on social networks and blogs.
-
vcr
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. -
minitest
minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. -
timecop
A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call. -
Spork
A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. -
Konacha
Test your Rails application's JavaScript with the mocha test framework and chai assertion library -
Fabrication
DISCONTINUED. This project has moved to GitLab! Please check there for the latest updates. -
Knapsack
Knapsack splits tests evenly across parallel CI nodes to run fast CI build and save you time. -
ActiveMocker
Generate mocks from ActiveRecord models for unit tests that run fast because they don’t need to load Rails or a database. -
Wrong
Wrong provides a general assert method that takes a predicate block. Assertion failure messages are rich in detail. -
RR
RR is a test double framework that features a rich selection of double techniques and a terse syntax. ⛺ -
turbo_tests
Run RSpec tests on multiple cores. Like parallel_tests but with incremental summarized output. Originally extracted from the Discourse and Rubygems source code. -
RSpecTracer
RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests accelerator, and coverage reporter tool for RSpec. It maintains a list of files for each test, enabling itself to skip tests in the subsequent runs if none of the dependent files are changed. It uses Ruby's built-in coverage library to keep track of the coverage for each test.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Test Tube or a related project?
README
Test Tube
A test tube to conduct software experiments 🧪
Installation
Add this line to your application's Gemfile:
gem "test_tube"
And then execute:
bundle
Or install it yourself as:
gem install test_tube
Usage
To make TestTube available:
require "test_tube"
Assuming we'd like to experiment on the answer to the Ultimate Question of Life, the Universe, and Everything with the following matcher:
class BeTheAnswer
def matches?
42.equal?(yield)
end
end
A matcher is an object that responds to the matches?
method with a block
parameter representing the actual value to be compared.
Back to our Ruby experiments, one possibility would be to invoke
a whole block
of code:
block_of_code = -> { "101010".to_i(2) }
experiment = TestTube.invoke(isolate: false, matcher: BeTheAnswer.new, negate: false, &block_of_code)
# => <TestTube actual=42 error=nil got=true>
experiment.actual # => 42
experiment.error # => nil
experiment.got # => true
An alternative would be to pass
directly the actual value as a parameter:
actual_value = "101010".to_i(2)
experiment = TestTube.pass(actual_value, matcher: BeTheAnswer.new, negate: false)
# => <TestTube actual=42 error=nil got=true>
experiment.actual # => 42
experiment.error # => nil
experiment.got # => true
Matchi matchers
To facilitate the addition of matchers, a collection is available via the Matchi project.
Let's use a built-in Matchi matcher:
gem install matchi
require "matchi"
An example of successful experience:
experiment = TestTube.invoke(
isolate: false,
matcher: Matchi::Matcher::RaiseException.new(NoMethodError),
negate: false
) { "foo".blank? }
# => <TestTube actual=#<NoMethodError: undefined method `blank?' for "foo":String> error=nil got=true>
experiment.actual # => #<NoMethodError: undefined method `blank?' for "foo":String>
experiment.error # => nil
experiment.got # => true
Another example of an experiment that fails:
experiment = TestTube.invoke(
isolate: false,
matcher: Matchi::Matcher::Equal.new(0.3),
negate: false,
&-> { 0.1 + 0.2 }
) # => <TestTube actual=0.30000000000000004 error=nil got=false>
experiment.actual # => 0.30000000000000004
experiment.error # => nil
experiment.got # => false
Finally, an experiment which causes an error:
experiment = TestTube.invoke(
isolate: false,
matcher: Matchi::Matcher::Match.new(/^foo$/),
negate: false
) { BOOM }
# => <TestTube actual=nil error=#<NameError: uninitialized constant BOOM> got=nil>
experiment.actual # => nil
experiment.error # => #<NameError: uninitialized constant BOOM>
experiment.got # => nil
Code isolation
When experimenting tests, side-effects may occur. Because they may or may not be
desired, an isolate
option is available.
Let's for instance consider this block of code:
greeting = "Hello, world!"
block_of_code = -> { greeting.gsub!("world", "Alice") } # => #<Proc:0x00007f87f71b9690 (irb):42 (lambda)>
By setting the isolate
option to true
, we can experiment while avoiding
side effects:
experiment = TestTube.invoke(
isolate: true,
matcher: Matchi::Matcher::Eql.new("Hello, Alice!"),
negate: false,
&block_of_code
) # => <TestTube actual="Hello, Alice!" error=nil got=true>
greeting # => "Hello, world!"
Otherwise, we can experiment without any code isolation:
experiment = TestTube.invoke(
isolate: false,
matcher: Matchi::Matcher::Eql.new("Hello, Alice!"),
negate: false,
&block_of_code
) # => <TestTube actual="Hello, Alice!" error=nil got=true>
greeting # => "Hello, Alice!"
Contact
- Source code: https://github.com/fixrb/test_tube
- Chinese blog post: https://ruby-china.org/topics/41390
- Japanese blog post: https://qiita.com/cyril/items/36174b619ff1852c80ec
Versioning
Test Tube follows Semantic Versioning 2.0.
License
The gem is available as open source under the terms of the MIT License.
This project is sponsored by:
*Note that all licence references and agreements mentioned in the Test Tube README section above
are relevant to that project's source code only.