silentbicycle / lunatest

xUnit-style + randomized unit testing framework for Lua (and C projects using Lua, etc.)
84 stars 23 forks source link

Add an assert_not_error function #24

Open xordspar0 opened 5 years ago

xordspar0 commented 5 years ago

Currently if I want to test that a function runs normally and doesn't return an error, I just run the function and don't try to catch the error.

function t.test_no_errors()
  might_error()
end

This is fine because lunatest runs all test cases inside pcall. However, if my function does return an error, lunatest reports the test case as having an error rather than a failed assertion. I would like to be able to consider this case as a failure, not a general error.