← ClaudeAtlas

nette-testerlisted

Use this skill whenever writing, modifying, or running .phpt test files with Nette Tester. Invoke for any task involving Tester\Assert methods (Assert::same, Assert::match, Assert::exception, etc.), test bootstrap setup, vendor/bin/tester commands, or debugging failing test output (.expected/.actual files). Also use when the user needs to write tests for a Nette project and asks about test structure, the test() function, testException(), or assertion methods. This skill is specifically for Nette Tester – do not use for PHPUnit, Pest, Jest, Vitest, or other testing frameworks, and do not use for general PHP testing without Nette context.
nette/agent-plugins · ★ 44 · Testing & QA · score 81
Install: claude install-skill nette/agent-plugins
## Testing with Nette Tester Nette Tester is a testing framework for PHP. Test files use the `.phpt` extension by convention; the runner also collects `*Test.php`. Two failure modes worth knowing before writing a single test: - **A test that executes no assertion is an error** – `Error: This test forgets to execute an assertion.` (exit code 178). It is on by default via `Environment::setup()`. - **`exit()` / `die()` in a test ends it with code 0, i.e. as a PASS.** Use `Assert::fail()` to fail deliberately. ```shell composer require nette/tester --dev ``` ### Bootstrap File The bootstrap file should set up the Tester environment and enable helper functions: ```php <?php declare(strict_types=1); require __DIR__ . '/../vendor/autoload.php'; Tester\Environment::setup(); Tester\Environment::setupFunctions(); // enables test(), testException(), testNoError(), setUp() ``` ### Basic Test Structure ```php <?php declare(strict_types=1); use Tester\Assert; require __DIR__ . '/../bootstrap.php'; test('Calculator adds numbers correctly', function () { $calc = new App\Model\Calculator; Assert::same(5, $calc->add(2, 3)); }); test('Calculator throws on division by zero', function () { $calc = new App\Model\Calculator; Assert::exception( fn() => $calc->divide(10, 0), \DivisionByZeroError::class, ); }); ``` Key points: - Use the `test()` function for each test case - The first parameter of `test()` should be a clear description of what is being tested - Do not ad