Description
Let Brutal shape for you in no time a huge, framework-less vanilla Ruby file describing the actual behavior of your code through as many combinations of contexts as needed.
By delegating to Brutal the repetitive (and redundant) task of writing tests, you'll be able to focus on your core business: the code itself.
Brutal ππ¨ alternatives and similar gems
Based on the "Testing" category.
Alternatively, view brutal 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 Brutal ππ¨ or a related project?
README
Brutal ππ¨
A code-first approach to automate the writing of unit tests.
Intro
I don't like tests. It's not DRY. -- Matz
Overview
Let Brutal shape for you in no time a huge, framework-less vanilla Ruby file describing the actual behavior of your code through as many combinations of contexts as needed.
By delegating to Brutal the repetitive (and redundant) task of writing tests, you'll be able to focus on your core business: the code itself.
Warning
Brutal development process does not prevent from bugs.
As a picture of the behavior of the code, a generated test suite is wrong as long as the code is wrong, regardless of whether all true expectations.
However, this document becomes relevant when it shows that the code behaves as it is supposed to. It is therefore important to read it well. This is the price for Brutal-Driven Development.
Installation
Add this line to your application's Gemfile:
gem "brutal"
And then execute:
$ bundle install
Or install it yourself as:
$ gem install brutal
Quick Start
Just type brutal
in a Ruby project's folder and watch the magic happen.
Usage
The brutal.yml
file is a manifest you can use to define your Brutal meta-spec.
It has 4 top-level sections:
header
- Specifies the code to execute before generating the test suite.subject
- Specifies the template of the code to be declined across contexts.contexts
- Specifies a list of variables to populate the subject's template.actuals
- Specifies templates to challenge evaluated subjects & get results.
Getting started
- Create a
brutal.yml
file in your application's root directory. The following examplebrutal.yml
defines the shape of a Hello test suite:
---
subject: |
"Hello " + "%{string}"
contexts:
string:
- Alice
- Bob
actuals:
- "%{subject}.to_s"
- "%{subject}.length"
Run the
brutal
command from the same directory.Read the generated
test.rb
file in the same directory:
# Brutal test suite
# ------------------------------------------------------------------------------
actual = begin
"Hello " + "Alice"
end
raise if actual.to_s != "Hello Alice"
raise if actual.length != 11
# ------------------------------------------------------------------------------
actual = begin
"Hello " + "Bob"
end
raise if actual.to_s != "Hello Bob"
raise if actual.length != 9
More examples
https://github.com/fixrb/brutal/raw/main/examples/
Rake integration example
A generated test.rb
file could be matched as follows:
Rake::TestTask.new do |t|
t.pattern = "test.rb"
end
Test suite
Brutal's test set is brutally self-generated here: ./test.rb
Contact
- Source code: https://github.com/fixrb/brutal
Versioning
Brutal 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 Brutal ππ¨ README section above
are relevant to that project's source code only.