summaryrefslogtreecommitdiffstats
path: root/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md
diff options
context:
space:
mode:
authorCorentin Le Gall <corentinlgs@gmail.com>2018-07-19 15:57:30 +0200
committerCorentin Le Gall <corentinlgs@gmail.com>2018-07-24 14:42:12 +0200
commitc96df58a88b60c7501b3c8a758c0277c17088371 (patch)
tree1e982c565a4fd0ba65a382cc1cba97efe891c34b /docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md
parent55673d50338f041763e6e38f38ea3fc311f2bdc1 (diff)
Changed doc to GitBook format + added doc
-Changed README.md to a complet GitBook doc. -Added explanations about EvtGrpReceived functions. -Corrected mistakes + reduced lines length. Change-Id: I1a077ddf6acb520a9158de658d3c09b12a2029d4 Signed-off-by: Corentin Le Gall <corentinlgs@gmail.com>
Diffstat (limited to 'docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md')
-rw-r--r--docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md
new file mode 100644
index 0000000..482b98d
--- /dev/null
+++ b/docs/WriteYourTests/Reference/LuaUnitAssertionFunctions/4_ErrorAssertions.md
@@ -0,0 +1,30 @@
+# Error assertions
+
+Error related assertions, to verify error generation and error messages.
+
+* **_AFT.assertError(func, ...)**
+
+ Assert that calling functions func with the arguments yields an error. If the function does not yield an error, the assertion fails.
+
+ Note that the error message itself is not checked, which means that this function does not distinguish between the legitimate error that you expect and another error that might be triggered by mistake.
+
+ The next functions provide a better approach to error testing, by checking explicitly the error message content.
+
+>**Note**
+>When testing LuaUnit, switching from assertError() to assertErrorMsgEquals() revealed quite a few bugs!
+
+* **_AFT.assertErrorMsgEquals(expectedMsg, func, ...)**
+
+ Assert that calling function func will generate exactly the given error message. If the function does not yield an error, or if the error message is not identical, the assertion fails.
+
+ Be careful when using this function that error messages usually contain the file name and line number information of where the error was generated. This is usually inconvenient. To ignore the filename and line number information, you can either use a pattern with assertErrorMsgMatches() or simply check if the message contains a string with assertErrorMsgContains() .
+
+* **_AFT.assertErrorMsgContains(partialMsg, func, ...)**
+
+ Assert that calling function func will generate an error message containing partialMsg . If the function does not yield an error, or if the expected message is not contained in the error message, the assertion fails.
+
+* **_AFT.assertErrorMsgMatches(expectedPattern, func, ...)**
+
+ Assert that calling function func will generate an error message matching expectedPattern . If the function does not yield an error, or if the error message does not match the provided pattern the assertion fails.
+
+ Note that matching is done from the start to the end of the error message. Be sure to escape magic all magic characters with % (like -+.?\*) . \ No newline at end of file