From 239bd24ec8587024952a998b23b8cea4f0cd6d7b Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 28 Mar 2024 17:06:29 +0100 Subject: [PATCH] You don't need to use test_status anymore :3 --- README.md | 19 ++++++------------- addons/besseretests/src/testclass.gd | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 49035bd..e65a6b7 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ extends BessereTestsTest # You can name this whatever you want as long as the function is prefixed with 'test_'. # If not, it will not be run. func test_example() -> void: - # Logging examples + # Logging examples ldiag("DIAGNOSTIC MESSAGE") lverb("VERBOSE MESSAGE") linfo("INFORMATIONAL MESSAGE") @@ -51,24 +51,17 @@ func test_example() -> void: lerror("ERROR MESSAGE") #await lcrash("Something horrible happened") # Must be awaited, uncomment for a little nuke - # Test result (must be set or Bessere Tests will complain) - # -> Test status - # Can be either 0 (ok), 1 (warn), 2 (error) or 3 (skip). Any other value will be marked as invalid. - test_status = 0 - # -> Test message - # Can be set to any string you like, or can be unset. - # Would of course be useful to leave a message when 'test_status' is set to anything but 0. - test_message = "Hello Test!" + # Test result + # You can use `ok(message)`, `warn(message)`, `error(message)` or `skip(message)` to set your test result. + ok("Hello Test!") # You can create multiple tests btw. func test_proprietary_blob() -> void: - test_status = 2 - test_message = "Not open source." + error("Not open source.") # Some unimplemented test func test_unimplemented() -> void: - test_status = 3 - test_message = "TODO" + skip() ``` Use this example to build your tests. And remember: You can have multiple test files (we call them "test suites" or "suites" for short). diff --git a/addons/besseretests/src/testclass.gd b/addons/besseretests/src/testclass.gd index 16fe4ad..0999940 100644 --- a/addons/besseretests/src/testclass.gd +++ b/addons/besseretests/src/testclass.gd @@ -24,3 +24,17 @@ func linfo(message: String) -> void: rts.linfo(message, name + ":" + lfunc) func lwarn(message: String) -> void: rts.lwarn(message, name + ":" + lfunc) func lerror(message: String) -> void: rts.lerror(message, name + ":" + lfunc) func lcrash(message: String) -> void: await rts.lcrash(message, name + ":" + lfunc) + +# Easier results management +func rok(message: String = "") -> void: + test_status = 0 + test_message = message +func rwarn(message: String = "") -> void: + test_status = 1 + test_message = message +func rerror(message: String = "") -> void: + test_status = 2 + test_message = message +func rskip(message: String = "") -> void: + test_status = 3 + test_message = message