---
schema_version: "1"
id: 837e0b5735a6959dab0d0a2a34fe2a4302f53164dd01c61d53d8bf6abb76cee2
title: BeforeClass Annotation (Developer Preview)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_classes_annotation_BeforeClass.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_BeforeClass.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0a98da962c3abead13eebec99c3f8149e393528761afd2e4d2ca3857262f04c0
description: Use the BeforeClass annotation to set up test data shared across methods within an integration test class.
---
# BeforeClass Annotation (Developer Preview)

Use the BeforeClass annotation to set up test data shared across methods within an integration test class.

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/images/icon_note.png)

#### Note

The Apex Integration Tests feature is available as a developer preview in scratch orgs in Summer ’26 (API version 67.0) and later. The feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Don’t implement functionality developed with these commands or tools in your production package.

The annotation is applied to a static method that runs once before the integration test methods in a class. Use this annotation to create data shared by the test methods. If the method completes successfully, the platform commits its transaction automatically. Don’t call Test.commitTestOnly() from a @BeforeClass method. If the method fails, the integration test methods fail.

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_AuraEnabled.htm "AuraEnabled Annotation")
- [Next →](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_deprecated.htm "Deprecated Annotation")

#### See Also

- [Apex Integration Tests (Developer Preview)](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_integration_testing.htm "Use Apex integration tests to write end-to-end tests that exercise real interactions between your Salesforce org and external services, including Agentforce and Data 360, as well as HTTP endpoints. Unlike standard Apex unit tests, integration tests relax callout restrictions and transaction rollback semantics, so your tests can make real service calls, commit data mid-transaction, and make assertions on expected outcomes. As a developer preview feature, integration tests are available only in scratch orgs. You can’t run them in production orgs or during metadata deployments.")