> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing

> Learn how to test Gazelle extensions for Bazel using golden BUILD.in and BUILD.out fixtures with the gazelle_generation_test rule for Go or Starlark generators.

Gazelle has a fantastically easy test fixture, using “golden” files. These can be used for extensions written either in Go or in Starlark (which is great since you can use the tests to verify a port from Go to Starlark)

Each test fixture is just a folder containing:

* `WORKSPACE` (just as a marker file)
* `BUILD.in` - what the actual BUILD file looks like before running Gazelle
* `BUILD.out` - what the expected BUILD file looks like after running Gazelle
* Other files that exist in the package and Gazelle may read

To turn a fixture into a test, use a `gazelle_generation_test` rule. Here's a [convenient wrapper](https://github.com/aspect-build/aspect-gazelle/blob/main/common/gazelle.bzl) that we use in Aspect CLI to handle dotfiles.

## Example

Here's a simple example with JSON files that participate in a dependency graph. Imagine our repository uses these to configure a code generator, and we want BUILD files to execute that generator using a custom rule called `x_lib`: [see the full test fixture](https://gist.github.com/alexeagle/a7b9daa6c565318dd68f5c572fd4b82e).
