[−][src]Module fluid::wiki::fact
A #[fact]
is a simple concrete fact to be verified. For example:
#[fact] fn cerberus_has_3_heads() { number_of_faces("Cerberus").should().be_equal_to(3) .because("that's how Cerberus is described"); }
If the test fails, it displays a nice error message:
failures:
---- cerberus_has_3_heads stdout ---- The test failed at src/main.rs:5: number_of_faces ( "Cerberus" ) has the value 1. It should be equal to 3 but it is not. This test should pass because that's how Cerberus is described.
It is possible to use standard assertions inside of the fact
function,
but it makes few sense, because the whole point of fact
is that it can
print a prettified error message in association with should()
.
In contrast, if for one or another reason you do not want to use the custom
attribute, you can replace it with a call to the fact_
macro:
#[test] fn cerberus_has_3_heads() { fact_!(number_of_faces("Cerberus")).should().be_equal_to(3) .because("that's how Cerberus is described"); }