A code-first approach to automate the writing of unit tests.
I don't like tests. It's not DRY. -- Matz
Let Brutal craft for you in no time a (potentially huge) framework-less vanilla Ruby file describing the actual behavior of your code across as many context combinations as necessary.
By delegating to Brutal the repetitive (and redundant) task of writing tests, you will be able to focus on your core business: the code itself.
The Brutal-Driven Development process does not prevent bugs from appearing in the code.
A generated test suite acts as a picture of the code's behavior. Therefore, if the code is wrong, the picture of the code's behavior will also be wrong.
The mere fact that all expectations are true does not mean that the code behaves as it should.
It is therefore the responsibility of the developer to analyze the generated behavioral pictures to ensure that the code reacts as it is supposed to according to the contexts in which it is evaluated.
Add this line to your application's Gemfile:
gem "brutal", ">= 1.6.0.beta4", require: falseAnd then execute:
bundle installOr install it yourself as:
gem install brutal --preBrutal needs configuration files in YAML format to know how to write tests.
Configuration file names are suffixed by _brutal.yaml and composed of 7 top-level sections:
- header- Specifies a block of lines to be executed once before all examples.
- before- Specifies a block of lines to be executed before each example.
- 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.
- after- Specifies a block of lines to be executed after each example.
- footer- Specifies a block of lines to be executed once after all examples.
The brutal command comes with several options you can use to customize Brutal's behavior.
For a full list of options, run the brutal command with the --help flag:
brutal --helpUsage: brutal [options] [files or directories]
    --format=FORMAT Choose "ruby" (default).
    --help          Display this help.
    --version       Display the version.Assuming that in the workspace there is a configuration file named user_brutal.yaml, the test suite can be generated via one of these commands:
brutal user_brutal.yamlor:
brutal .or even:
brutalThis would create a test_user.rb file containing the test suite.
Assuming now that in the workspace there are a large number of configuration files named in the spec/ folder, the complete test suite could be generated recursively via this command:
brutal spec/This would create one test file per configuration file matching ./spec/**/*_brutal.yaml in to ./spec/**/test_*.rb.
https://github.com/fixrb/brutal/tree/main/examples/
Generated test suite files could be matched as follows:
Rake::TestTask.new do |t|
  t.pattern = "**/test_*.rb"
end- Source code: https://github.com/fixrb/brutal
Brutal follows Semantic Versioning 2.0.
The gem is available as open source under the terms of the MIT License.
This project is sponsored by Sashité:



