---
schema_version: "1"
id: deb5119a984fa287901a477a7f731b09bcca44b701e972b1b90cc0288e4cca27
title: Specify Unpackaged Metadata or Apex Access for Package Version Creation Tests for Second-Generation Managed Packages
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform-pkg-exchange/managed_packaging/guides/second-generation/sfdx-dev-dev2gp-unpackaged-md.md
canonical_url: https://developer.salesforce.com/docs/platform/pkg2-dev/guide/sfdx-dev-dev2gp-unpackaged-md.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 792f2d1e3ca5b7401fddbc11881f2ff256511ce60cb2a32be21c88f80e485434
products:
  - Second-Generation Managed Packaging Developer Guide
  - merged-docs
---

# Specify Unpackaged Metadata or Apex Access for Package Version Creation Tests for Second-Generation Managed Packages

For scenarios where you require metadata that isn’t part of your second-generation managed package, but is necessary for Apex test runs, you can specify the path containing unpackaged metadata in the `sfdx-project.json` file. The unpackaged metadata isn’t included in the package and isn’t installed in subscriber orgs.

## Specify Unpackaged Metadata for Package Version Creation Tests

Specify the path to the unpackaged metadata in your `sfdx-project.json` file.

In this example, metadata in the `my-unpackaged-directory` is available for test runs during the package version creation of the TV_unl package.

```nolang
"packageDirectories": [
    {
        "path": "force-app",
        "package": "TV_unl",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": true,
        "unpackagedMetadata": {
            "path": "my-unpackaged-directory"
        }
    },
]
```

The `unpackagedMetadata` attribute is intended for metadata that isn’t part of your package. You can’t include the same metadata in both an unpackaged directory and a packaged directory.

## Manage Apex Access for Package Version Creation Tests

Sometimes the Apex tests that you write require a user to have certain permission sets or permission set licenses. Use the `apexTestAccess` setting to assign permission sets and permission set licenses to the user in whose context your Apex tests get run at package version creation.

```nolang
"packageDirectories": [
    {
        "path": "force-app",
        "package": "TV_unl",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": true,
        "unpackagedMetadata": {
            "path": "my-unpackaged-directory"
        },
        "apexTestAccess": {
               "permissionSets": [
                   "Permission_Set_1",
                   "Permission_Set_2"
               ],
               "permissionSetLicenses": [
                   "SalesConsoleUser"
               ]
           }

    },
]
```

**note:** To assign user licenses, use the [runAs Method](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm). User licenses can't be assigned in the `sfdx-project.json` file.
