https://github.com/ybiquitous/easytest
Easy testing for Ruby
https://github.com/ybiquitous/easytest
ruby test
Last synced: 11 months ago
JSON representation
Easy testing for Ruby
- Host: GitHub
- URL: https://github.com/ybiquitous/easytest
- Owner: ybiquitous
- License: mit
- Created: 2022-10-04T09:39:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T07:06:08.000Z (about 2 years ago)
- Last Synced: 2025-07-27T15:06:05.663Z (11 months ago)
- Topics: ruby, test
- Language: Ruby
- Homepage: https://ybiquitous.github.io/easytest/
- Size: 200 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/rb/easytest)
[](https://github.com/ybiquitous/easytest/actions/workflows/ci.yml)
# Easytest
> makes you write tests easily
Easytest is a tiny testing framework for Ruby with a familiar DSL.
## Installation
Add this line to your `Gemfile` for Bundler:
```ruby
gem "easytest"
```
Or install it via `gem`:
```shell
gem install easytest
```
## Documentation
You can read more about Easytest on the [official website](https://ybiquitous.github.io/easytest/).
## Usage
This section explains easy usage.
First, put `test/addition_test.rb` as below:
```ruby
require "easytest"
extend Easytest::DSL
test "addition" do
expect(1 + 2).to_eq 2
end
```
Then, run `easytest`:
```console
$ easytest
FAIL test/addition_test.rb
✕ addition (should equal)
Expected: 2
Received: 3
# test/addition_test.rb:6:in `block in '
Tests: 1 failed, 0 passed, 1 total (1 files)
Time: 0.00087 seconds
```
Oops. Let's fix the failure:
```diff
- expect(1 + 2).to_eq 2
+ expect(1 + 2).to_eq 3
```
Then, run it again:
```console
$ easytest
PASS test/addition_test.rb
Tests: 1 passed, 1 total (1 files)
Time: 0.00077 seconds
```
The test now passes! 🎉
### Hooks
You can add hooks called `before` and `after` to each test case:
```ruby
before do
# set up something...
end
after do
# clean up something...
end
test "something" do
# test something...
end
```
### Skip
If you want to skip any cases, you can change `test` to `skip`:
```diff
- test "addition" do
+ skip "addition" do
```
Skipped cases will be reported as "skipped".
### Only
If you want to run only any cases, you can use `test` to `only`:
```diff
- test "addition" do
+ only "addition" do
```
Only cases with `only` will be run, and other cases will be skipped.
### To-do
If you want to write to-do cases, you can use `test` without a block:
```ruby
test "addition"
```
To-do cases will be reported as "todo".
### Watch
If you want to run tests immediately when changing code, specify the `--watch` option:
```shell
easytest --watch
```
This *watch* mode is useful during development.