I hope to do something more flexible than Python's unit testing framework where if something fails it stops everything. I won't be using asserts to do this because I don't wanting it to stop stuff, I want it to continue on! It will will probably be an object. I hope for it to somehow be compatible with the google app engine and also independent of it. So I hope to let the user specify if they want it to be part of the google app or just write the output directly to the terminal.
Yea, it's gonna have to be an object for that to work. So far I've come up with the methods that you can use:
Unit.assertTrue(boolean value)
Unit.assertFalse(boolean)
Unit.assertTrueFAIL(boolean)
Unit.assertFalseFAIL(boolean)
Unit.assertEqual(thing 1, thing 2)
Unit.assertNotEqual(thing 1, thing 2)
Unit.assertEqualFAIL(thing 1, thing2)
Unit.assertNotEqualFAIL(thing 1, thing 2)
The functions with "FAIL" in them will instead of using a nice if statement they will use an assert, so if the assert fails, it will stop everything. This allows things to where the code after it is absolutely DEPENDENT on the code above working correctly. This is great for when if something should stop at that point could perhaps, say, delete your whole database or enter a profoundly awesome loop that will not end.
If I have enough time, I will add to it:
Unit.assertTrueGIVE(boolean)
where the GIVE will return the value of what happened. So if you make a function call in it, it will return that function call's return value.
So it will be possible to do:
x=Unit.assertEqualGIVE(5,65) and will set x = to 5.
So theoretically, there will be no statements other than unit test calls in the unit test file. Nifty eh?
Any comments or feedback would be nice.
No comments:
Post a Comment