Test fixtures in Rust are string literals that define a mini-project environment for IDE or compiler tests, using a specific syntax to declare files, crates, and cursor positions. You write the fixture inside a raw string literal, often annotated with #[rust_fixture], where lines starting with //- define file paths and dependencies, and $0 marks the cursor location for analysis. The test framework parses this string to build a temporary database and runs your test logic against the generated code structure.
#[test]
fn test_fixture_example() {
let fixture = r#"
//- /main.rs crate:main deps:dep1
use dep1::foo;
fn main() { foo(); }
//- /lib.rs crate:dep1
pub fn foo() {}
"#;
// Parse fixture and run test logic
let (db, files) = RootDatabase::from_ra_fixture(fixture, MiniCore::default());
assert!(db.is_valid());
}