Set Up Your First Test in a Data Pack
Create the Test Structure
Inside your data pack's namespace folder, create a new directory path: functions/test/. This is where all your test files will live.
Write a Basic Test Function
Create a new .mcfunction file in the test folder—for example, my_first_test.mcfunction. Start with a simple assertion:
`
/assert block ~ ~ ~ stone
/succeed
`
This test checks if the block at your position is stone, then passes if true.
Add Header Directives
At the top of your test file, you can add directives to configure the test environment. For example:
`
@template flat
@timeout 100
`
The @template directive loads a predefined world structure, and @timeout sets how many ticks the test can run before failing.
Run Your Test
Load your data pack in a world and run /test runall to execute all tests, or /test run <namespace>:test/my_first_test to run your specific test. Check the chat output for pass/fail results.