UTMT - Unit Tests Macros (for Tests)
Goal
The goal of this project is to create new macros for unit tests improving.
Features
This project provides the following features.
assert_all(...)
This macro allows to set several assertion in a single assertion like AssertAll(...) of the excellent JUnit 5.x test framework for Java.
The number of assertion rules is unlimited.
Examples
invalid assertions
assert_all!;
With this example above, we can see that the second and third assertions are false. The assert_all!(...) macro will test all assertions first,
and store the false assertion for a final report. While all assertions are done, the assert_all!(...) shows the final results by indicating:
- the false assertions list,
- the number of false assertions,
- run a
panic!macro to inform theunittestrust framework that this test is failed.
valid assertions
assert_all!;
setup!({...})
This macro is corresponding to the setUp() method of the JUnit framework like. But the difference is the setup!() must be implemented in each test method first.
teardown!({...})
This macro is corresponding to the tearDown() method of the JUnit framework like. But the difference is the teardown!() must be implemented in each test method first.
Examples
The setup!({...}) block will be executed first. But the teardown!({...}) will be delayed while the assert!(...) macro have been executed. The teardown({...}) will ensure to be executed whatever the assert!(...) result.
assert_slices_eq!(...) and assert_slices_ne!(...)
These macros compare 2 slices and panic only if these slices are equals for the first macro or not equals for the second one. The content, size and order are importants.
Examples
- For
assert_slices_eq!(...):
valid assertion
assert_slices_eq!;
invalid assertion
assert_slices_eq!;
- For
assert_slices_ne!(...):
valid assertion
assert_slices_ne!;
invalid assertion
assert_slices_ne!;
assert_same_slices!(...) and assert_no_same_slices!(...)
These macros compare 2 slices and panic only if these slices haven't got the same content first the first macro, or same content for the second one. Same content, means same values, same size but the order is not taking account.
Examples
- For
assert_same_slices!(...):
valid assertion
assert_same_slices!;
invalid assertion
assert_same_slices!;
- For
assert_not_same_slices!(...):
valid assertion
assert_not_same_slices!;
invalid assertion
assert_not_same_slices!;
Other features
See the utmt documentation on utmt.
Authors and acknowledgement
Help will be appreciated. All tools will be developed with rust technology. If you have new ideas, your welcome!
License
This project is under MIT licence.
Project status
This project is under development and all contributions are welcome.
These tools are provided without any guaranties.