> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/v6.x/testing/testing-coldbox-applications/integration-testing/test-setup.md).

# Request Setup()

Since we are simulating a browser, the testing framework needs to know when to prepare a new virtual request internally.  This is achieved via the `setup()` method provided to us via the `BaseTestCase` object.  This method internally will simulate a new virtual request, if **NOT**, **every test case will be treated as if you are in the same request.**

The best way to accomplish this is to leverage the `beforeEach()` life-cycle event method.  This makes sure that each spec execution is a new virtual request.

```javascript
function run() {
	describe( "Main Handler", function() {
		
		beforeEach( function( currentSpec ) {
			// Setup as a new ColdBox request, VERY IMPORTANT. ELSE EVERYTHING LOOKS LIKE THE SAME REQUEST.
			setup();
		} );
	
		it( "can render the homepage", function() {
			var event = this.get( "main.index" );
			expect( event.getValue( name = "welcomemessage", private = true ) ).toBe( "Welcome to ColdBox!" );
		} );
	
		it( "can render some restful data", function() {
			var event = this.post( "main.data" );
	
			debug( event.getHandlerResults() );
			expect( event.getRenderedContent() ).toBeJSON();
		} );
	});
	
}
```


---

# 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://coldbox.ortusbooks.com/v6.x/testing/testing-coldbox-applications/integration-testing/test-setup.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.
