Is it possible to create custom Assertions for Unity Test Tools?
I'd like to create an assertion that works like the built in assertions.
For example:
Assert.AreNear(vectorA, vectorB, 0.01f); // doesn't exist
Right now I have to write it like this:
Assert.Less((vectorA - vectorB).magnitude, 0.01f); // readability is bad for complicated tests
I could define my own wrappers for Assert in some CustomAssertClass like this:
CustomAssertClass.AreNear(vectorA, vectorB, 0.01f); // editor brings you to the wrong spot
but when you click on a failed assertion from the editor, it doesn't bring you to the test, it brings you to the CustomAssertClass, which is a pain in the butt.
Is there a clean way to extend the Assertions?
Answer by Tomek-Paszek · Nov 20, 2015 at 10:13 AM
Hi NianticMortoc! Currently there is no way as far as I know. It should be possible and I'll give it a look at some point but can't promise a date. Maybe we could somehow use DebuggerStepThroughAttribute. Thanks for suggestion! Tomek
The DebuggerStepThrough option would be fantastic. At least now I know it isn't possible yet, thanks for the response.
Your answer
Follow this Question
Related Questions
Player Vehicle Clipping Through Only Y-Axis 0 Answers
Why does Play In Editor close my currently Running Standalone Copy 0 Answers
Can i run tests in Unity test runner without creating asmdef files? 0 Answers
How to test an objects Unity serializability? 0 Answers
Unity wont let me run a build and play in editor at the same time? 1 Answer