# Test Particles

Test ordinary code locally, then validate the deployed function through SQL.

Source: https://particledb.ai/particles/testing/

## Unit-test the function

Save the function from [your first Particle](/particles/overview/) as `tools.py`, then run this alongside it:

```python
from tools import priority

assert abs(priority(0.9, 0.8) - 0.72) < 1e-10
assert priority(0.0, 1.0) == 0.0
```

## Test the SQL call

Load the module in a disposable server, then run:

```sql
SELECT priority(0.9, 0.8) AS score;
SELECT priority(NULL, 0.8) AS missing_score;
```

Check that the first result is approximately 0.72 and the second is NULL.

## Test application behavior

Include boundary values, invalid types, dependency failures and realistic input sizes. Check the client's error handling as well as successful output.

## Test a restart

Restart with the same configuration and data directory. Call the function again. This confirms that your selected loading or deployment method matches how the application will run.

## Related

[Documentation home](/docs/) · [Troubleshooting](/guides/troubleshooting/)
