> For the complete documentation index, see [llms.txt](https://testbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testbox.ortusbooks.com/getting-started/testbox-xunit-primer/test-methods.md).

# Test Methods

TestBox discovers test methods in your bundle CFC by applying the following discovery rules:

* Any method that has a test annotation on it
* Any public method that starts or ends with the word test

```javascript
// Via inline annotation
function shouldBeAwesome() test{}

/**
* Via comment annotation
* @test
*/
function shouldBeAwesome(){}

// via conventions
function testShouldDoThis(){}
function shouldDoThisTest(){}
```

Each test method will test the state of the SUT (software under test) or sometimes referred to as code under test. It will do so by asserting that actual values from an execution match an expected value or condition. TestBox offers an assertion library that you have available in your bundle via the injected variable $assert. You can also use our expectations library if you so desire, but that is mostly used in our BDD approach.

```javascript
function testIncludes(){
       $assert.includes( "hello", "HE" );
       $assert.includes( [ "Monday", "Tuesday" ] , "monday" );
}
```

Each test function can also have some cool annotations attached to it.

| Argument | Required | Default | Type        | Description                                                                                                                                                                                                                 |
| -------- | -------- | ------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| labels   | false    | ---     | string/list | The list of labels this test belongs to                                                                                                                                                                                     |
| skip     | false    | false   | boolean/udf | A boolean flag that makes the runners skip the test for execution. It can also be the name of a UDF in the same CFC that will be executed and MUST return a boolean value.                                                  |
| retries  | false    | 0       | numeric     | How many extra times to run the test when it fails or errors, with its `setup()` and `teardown()`. `0` inherits the bundle `retries` annotation or the global `retries` option. See [Retries](/browser-testing/retries.md). |

{% tabs %}
{% tab title="BoxLang" %}

```groovy
@retries( 2 )
function testChargesACardInTheSandbox() {
    $assert.isEqual( "succeeded", gateway.charge( 100 ).status )
}
```

{% endtab %}

{% tab title="CFML" %}

```cfscript
function testChargesACardInTheSandbox() retries="2"{
    $assert.isEqual( "succeeded", gateway.charge( 100 ).status );
}
```

{% endtab %}
{% endtabs %}

A test method can also attach files, such as screenshots or logs, to its result with `attach( path, type, name )`. See [Attachments](/browser-testing/attachments.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://testbox.ortusbooks.com/getting-started/testbox-xunit-primer/test-methods.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
