fail


Description:

[ Version ( since = "2.30" ) ]
public void fail ()

Indicates that a test failed.

This function can be called multiple times from the same test. You can use this function if your test failed in a recoverable way.

Do not use this function if the failure of a test could cause other tests to malfunction.

Calling this function will not stop the test from running, you need to return from the test function yourself. So you can produce additional diagnostic messages or even continue running the test.

If not called from inside a test, this function does nothing.

Note that unlike skip and incomplete, this function does not log a message alongside the test failure. If details of the test failure are available, either log them with message before fail, or use fail_printf instead.

Example: Mark a test as failed:

public static int main (string[] args) {
Test.init (ref args);

Test.add_func ("/valadoc/driver-0.14.x", () => {
// Mark test case as failed
Test.fail ();

// Test case is still running until we return / exit:
message ("still running");
});

Test.run ();
return 0;
}

valac --pkg glib-2.0 GLib.Test.fail.vala

./GLib.Test.fail --verbose


Namespace: GLib.Test
Package: glib-2.0