# Mocking Methods

Once you have created a mock object, you can use it like the real object, which will respond exactly as it was coded. However, you can override its behavior by using the mocking methods placed on the mocked object at run-time. The methods that you can call upon in your object are the following (we will review them in detail later):

<table data-header-hidden><thead><tr><th>Method Name</th><th width="148.33333333333331">Return Type</th><th>Description</th></tr></thead><tbody><tr><td>Method Name</td><td>Return Type</td><td>Description</td></tr><tr><td><code>$()</code></td><td>Object</td><td>Used to mock a method on the mock object that can return, throw or be a void method.</td></tr><tr><td><code>$args()</code></td><td>Object</td><td>Mock 1 or more arguments in sequential or named order. Must be called concatenated to a $() call and must be followed by a concatenated $results() call so the results are matched to specific arguments.</td></tr><tr><td><code>$getProperty(name, scope)</code></td><td>any</td><td>Retrieve any public or private internal state variable so you can do assertions and more mocking.</td></tr><tr><td><code>$property()</code></td><td>Object</td><td>Mock a property in the object on any scope.</td></tr><tr><td><code>querySim()</code></td><td>query</td><td>to denote columns. Ex: id, name 1 Luis Majano 2 Joe Louis</td></tr><tr><td><code>$results()</code></td><td>Object</td><td>Mock 1 or more results of a mock method call must be chained to a $() or $().$args() call</td></tr><tr><td><code>$spy( method )</code></td><td>Object</td><td>Spy on a specific method to check how often it has been called and with what arguments and results.</td></tr><tr><td><p><code>$throws(</code></p><p><code>type,</code></p><p><code>message,</code></p><p><code>datail,</code></p><p><code>errorcode</code></p><p><code>)</code></p></td><td>Object</td><td>This method tells MockBox that you want to mock a method that will throw an exception when called.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://testbox.ortusbooks.com/mocking/mockbox/mocking-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
