Skip to content

Test Model

raised()

raised() — returns string

Available in: test Category: Testing Functions

Used in legacy Wheels testing to catch errors or exceptions raised by a given CFML expression. It evaluates the expression and, if an error occurs, returns the type of the error. This is especially useful when writing tests to ensure that specific operations correctly trigger exceptions under invalid or unexpected conditions. By using raised(), you can assert that your code behaves safely and predictably when encountering errors.

NameTypeRequiredDefaultDescription
expressionstringyesString containing CFML expression to evaluate
1. Testing for a specific exception
// Assume updateUser() should throw an error if email is invalid
errorType = raised('model("user").updateUser({email="invalid-email"})');
assert("errorType eq Wheels.InvalidEmailException");

2. Using raised() in a test case
function testInvalidPassword() {
    var errorType = raised('model("user").login(username="jdoe", password="wrong")');
    writeOutput("Caught error type: " & errorType);
    // Output: Caught error type: Wheels.InvalidPassword
}

3. Catching any error
var errorType = raised('1 / 0'); // Division by zero
writeOutput(errorType);