I'm working on a rails project where I have a function which has to pass a lot of tests (hundreds\thousands calls to the function in it's unit test). I'm just looking for an easy way to assert the result (for example assert(class.foo(params)>0.6, true) to test foo's result is bigger than 0.6), and maybe have it print the line of the tests which didn't pass.
I'm used to this kind of unit testing from C\C++ programming, but from looking up online for a similar solution in rails I came up with gems like "MiniTest" where I have to encapsulate each assertion in a function (def \ assertion \ end), which triples the code's length and makes the whole process sisyphic and the code unreadable.
The bottom line: I'm looking for a way to create a new instance of my class, i = my_class.new, followed by many assertion: assert(i.foo(params)<0.6, true). If a test fails, it would be nice to be notified about the exact line.
Thanks!
Aucun commentaire:
Enregistrer un commentaire