Writes an error to the log and throws an exception if expected != actual. Returns String containing the error message written to the log.
Parameter | Type | Description |
---|---|---|
expected | Anything | The expected value. |
actual | Anything | The actual value. |
message | String | Custom message to use if the assertion fails. Message will be run through template evaluation against messageProperties so you can include details of the assertion failure in the message. |
messageProperties | Object | Object containing values to use with template evaluation. |
Example usage:
db.load(undefined, 0, 1, function(offset, array, totalCount){ var readNote = array[0]; Mojo.requireEqual(id, readNote.id); Mojo.requireEqual(1, totalCount); Mojo.requireFalse(readNote.text); // Save again all fields! note.text = '1'; note.modifiedTimestamp = 2; note.position = 3; note.color = '4'; db.saveNote(note); db.loadNoteById(id, function(tx, readNote){ Mojo.Log.logProperties(readNote); Mojo.requireEqual(id, readNote.id); Mojo.requireEqual('1', readNote.text); Mojo.requireEqual(2, readNote.modifiedTimestamp); Mojo.requireEqual(3, readNote.position); Mojo.requireEqual('4', readNote.color); // Done! recordResults(Mojo.Test.passed); });
0 Comments