You don't need to use test_status anymore :3

This commit is contained in:
JeremyStar™ 2024-03-28 17:06:29 +01:00
parent e0d8f0d125
commit 239bd24ec8
2 changed files with 20 additions and 13 deletions

View file

@ -43,7 +43,7 @@ extends BessereTestsTest
# You can name this whatever you want as long as the function is prefixed with 'test_'. # You can name this whatever you want as long as the function is prefixed with 'test_'.
# If not, it will not be run. # If not, it will not be run.
func test_example() -> void: func test_example() -> void:
# Logging examples # Logging examples
ldiag("DIAGNOSTIC MESSAGE") ldiag("DIAGNOSTIC MESSAGE")
lverb("VERBOSE MESSAGE") lverb("VERBOSE MESSAGE")
linfo("INFORMATIONAL MESSAGE") linfo("INFORMATIONAL MESSAGE")
@ -51,24 +51,17 @@ func test_example() -> void:
lerror("ERROR MESSAGE") lerror("ERROR MESSAGE")
#await lcrash("Something horrible happened") # Must be awaited, uncomment for a little nuke #await lcrash("Something horrible happened") # Must be awaited, uncomment for a little nuke
# Test result (must be set or Bessere Tests will complain) # Test result
# -> Test status # You can use `ok(message)`, `warn(message)`, `error(message)` or `skip(message)` to set your test result.
# Can be either 0 (ok), 1 (warn), 2 (error) or 3 (skip). Any other value will be marked as invalid. ok("Hello Test!")
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!"
# You can create multiple tests btw. # You can create multiple tests btw.
func test_proprietary_blob() -> void: func test_proprietary_blob() -> void:
test_status = 2 error("Not open source.")
test_message = "Not open source."
# Some unimplemented test # Some unimplemented test
func test_unimplemented() -> void: func test_unimplemented() -> void:
test_status = 3 skip()
test_message = "TODO"
``` ```
Use this example to build your tests. And remember: You can have multiple test files (we call them "test suites" or "suites" for short). Use this example to build your tests. And remember: You can have multiple test files (we call them "test suites" or "suites" for short).

View file

@ -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 lwarn(message: String) -> void: rts.lwarn(message, name + ":" + lfunc)
func lerror(message: String) -> void: rts.lerror(message, name + ":" + lfunc) func lerror(message: String) -> void: rts.lerror(message, name + ":" + lfunc)
func lcrash(message: String) -> void: await rts.lcrash(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