The expression that is expected to throw the exception.
The file name that the assert failed in. Should be left as default.
The file line that the assert failed in. Should be left as default.
If expression does not throw, will throw an UnitTestException.
1 // Makes sure it throws with the message "test" 2 void noThrow(){}; 3 void withThrow(){throw new Exception("test");}; 4 5 // Will throw an exception like "checkit.exception.UnitTestException@test/example.d(7): Expression did not throw" 6 noThrow.shouldThrow(); 7 // Will throw an exception like "checkit.exception.UnitTestException@test/example.d(7): Expression did not throw" 8 noThrow.shouldThrow!Exception(); 9 10 // Will throw an exception like "checkit.exception.UnitTestException@test/example.d(7): Expected <UnitTestException>, but throw <object.Exception>" 11 withThrow.shouldThrow!UnitTestException();
Used for asserting that a expression will throw an exception.