morq
Write unit tests like humans
Grammar
Since we are using a macro here, you need to wrap the following rules in morq!
macro.
Example:
morq!;
Chains
You use following chains to make the assertions more user friendly and readable.
- to
- be
- have
Equal
expect.to.be.equal;
expect.to.be.equal;
Close
To compare two given float
values
expect.to.be.close;
Not
Negates the chain.
expect.to.not.be.equal;
expect.to.not.be.equal;
expect.to.not.be.a;
A / An
To check the data type.
expect.to.be.an;
expect.to.not.be.a;
expect.to.be.a;
Empty
To check and see if the iterator is empty or not
expect.to.not.be.empty;
expect.to.not.be.empty;
LengthOf
To check the count of elements in an iterator
expect.to.not.have.lengthOf;
expect.to.have.lengthOf;
Contain
Given iterator must contain the element
expect.to.contain;
expect.to.not.contain;
Ok / Err
To check a Result enum
let res: = Ok;
morq!;
let res: = Err;
morq!;
Of course, you can combine it with not
:
let res: = Err;
morq!;
Roadmap
-
Adding more chain rules
-
Adding more assert (terminal)
-
Adding alias for existing terminal rules (e.g.
close_to
alias forclose
) -
Ability to add two or more asserts in one chain:
expect.to.be.equal.and.not.be.a;
FAQ
morq?
Means chicken in Farsi. Like a lazy chicken, you know.
Artwork: clipart-library.com
Author
Afshin Mehrabani
License
MIT
Inspired by http://chaijs.com and https://github.com/carllerche/hamcrest-rust