# Test and Suite Labels

Tests and suites can be tagged with TestBox labels. Labels allow you to further categorize different tests or suites so that when a runner executes with labels attached, only those tests and suites will be executed; the rest will be skipped. Labels can be applied globally to the component declaration of the test bundle suite or granularly at the test method declaration.

```javascript
component displayName="TestBox xUnit suite" labels="railo,stg,dev"{

     function setup(){
          application.wirebox = new coldbox.system.ioc.Injector();
          structClear( request );
     }

     function teardown(){
          structDelete( application, "wirebox" );
          structClear( request );
     }

     function testThrows(){
          $assert.throws(function(){
               var hello = application.wirebox.getInstance( "myINvalidService" ).run();
          });
     }

     function testNotThrows(){
          $assert.notThrows(function(){
               var hello = application.wirebox.getInstance( "MyValidService" ).run();;
          });
     }

     function testFailsShortcut() labels="dev"{
          fail( "This Test should fail when executed with labels" );
     }

}
```

## Direct Suite Name Matching

When using the `testSuites` filter (via a runner, the CLI, or `TestBox` directly), TestBox performs **direct suite name matching** at any nesting depth. This means if a suite's name exactly matches the filter value it will always be included — regardless of how deeply it is nested.

```javascript
// This suite will always be included when testSuites="My xUnit Suite"
component displayName="My xUnit Suite" {

     function testSomething(){
          $assert.isTrue( true );
     }
}
```

Targeting by name from the various runners:

```bash
# BoxLang CLI runner
./testbox/run --filter-suites="My xUnit Suite"

# CommandBox CLI runner
testbox run testSuites="My xUnit Suite"
```

```javascript
// Programmatically via TestBox
new testbox.system.TestBox(
    bundles    = "tests.specs",
    testSuites = "My xUnit Suite"
).run();
```


---

# 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/getting-started/testbox-xunit-primer/test-and-suite-labels.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.
