---
title: setUp()
framework: xctest
role: symbol
role_heading: Type Method
path: xctest/xctestcase/setup()
---

# setUp()

Provides an opportunity to customize initial state before a test case begins.

## Declaration

```swift
class func setUp()
```

## Mentioned in

Set Up and Tear Down State in Your Tests

## Discussion

Discussion The setUp() class method is called exactly once for a test case, before its first test method is called. Override this method to customize the initial state for all tests in the test case.

## See Also

### Related Documentation

- [setUp()](xctest/xctest/setup().md)

### Customizing Test Setup and Teardown

- [Set Up and Tear Down State in Your Tests](xctest/set-up-and-tear-down-state-in-your-tests.md)
- [addTeardownBlock(_:)](xctest/xctestcase/addteardownblock(_:)-2guon.md)
- [addTeardownBlock(_:)](xctest/xctestcase/addteardownblock(_:)-5zw6c.md)
- [tearDown()](xctest/xctestcase/teardown().md)
