Logo di Testing Pyramid

Testing Pyramid

Community
fatonh
testing-pyramid

Usa questa skill per scrivere test per un’app Symfony: test unitari, di integrazione (Kernel) e funzionali (WebTestCase), database di test, fixture/factory (Foundry) e cosa simulare. Usala quando l’attività riguarda test, PHPUnit, WebTestCase, KernelTestCase, fixture o copertura del codice.

Add to TypingMind

Panoramica

Pubblicato dafatonh
Repositorysymfony-skills
Nome della skilltesting-pyramid
Stelle
36
Fork
3
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da fatonh su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Testing Pyramid in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/fatonh/symfony-skills/tree/main/skills/testing-pyramid
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fatonh/symfony-skills.git /tmp/symfony-skills
mkdir -p .claude/skills
cp -r /tmp/symfony-skills/skills/testing-pyramid .claude/skills/testing-pyramid
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Testing Pyramid in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Testing Pyramid non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Testing Pyramid non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Testing Pyramid (Symfony + PHPUnit)

The shape

        ╱╲        Functional (few)   — WebTestCase: real HTTP kernel, real DB, full stack
       ╱──╲       Integration (some) — KernelTestCase: container + DB, no HTTP
      ╱────╲      Unit (many)        — plain PHPUnit: pure PHP, no container, no DB
     ╱──────╲

Most tests are fast unit tests of domain logic. A smaller layer of integration tests covers wiring + persistence. A thin top layer of functional tests covers the critical user-facing flows end-to-end. Don't invert it — a suite that's all WebTestCase is slow and brittle.

Unit tests — domain logic, no framework

Test value objects, aggregates, and services with their collaborators mocked. No container, no DB, milliseconds each.

php
final class OrderTest extends TestCase
{
    public function test_confirming_an_empty_order_is_rejected(): void
    {
        $order = Order::place();

        $this->expectException(\DomainException::class);
        $order->confirm();                       // invariant: can't confirm empty
    }

    public function test_adding_a_line_to_a_confirmed_order_is_rejected(): void
    {
        $order = Order::place();
        $order->addItem(Uuid::v7(), 2);
        $order->confirm();

        $this->expectException(\DomainException::class);
        $order->addItem(Uuid::v7(), 1);
    }
}

Mock only what you own and inject (ports/repositories). Don't mock value objects or the framework.

php
// ✅ mock the repository PORT
$orders = $this->createMock(OrderRepository::class);
$orders->method('ofId')->willReturn($existingOrder);
$service = new CancelOrderHandler($orders);

Integration tests — wiring + persistence

KernelTestCase boots the container; pull real services and hit a real (test) database. Use it to verify repository queries, Doctrine mapping, and service wiring.

php
final class OrderRepositoryTest extends KernelTestCase
{
    private EntityManagerInterface $em;
    private OrderRepository $repo;

    protected function setUp(): void
    {
        self::bootKernel();
        $this->em = self::getContainer()->get(EntityManagerInterface::class);
        $this->repo = self::getContainer()->get(OrderRepository::class);
    }

    public function test_find_active_by_customer_returns_only_active(): void
    {
        OrderFactory::createOne(['customerEmail' => 'a@x.io', 'status' => OrderStatus::Active]);
        OrderFactory::createOne(['customerEmail' => 'a@x.io', 'status' => OrderStatus::Cancelled]);

        $result = $this->repo->findActiveByCustomer('a@x.io');

        self::assertCount(1, $result);
    }
}

Functional tests — the real HTTP stack

WebTestCase sends a real request through the kernel. Reserve it for critical flows and contract checks (status codes, problem+json shape, auth).

php
final class CreateOrderTest extends WebTestCase
{
    public function test_post_orders_returns_201_with_location(): void
    {
        $client = static::createClient();

        $client->request('POST', '/api/orders', server: [
            'CONTENT_TYPE' => 'application/json',
        ], content: json_encode([
            'customerEmail' => 'buyer@example.com',
            'items' => [['productId' => Uuid::v7()->toRfc4122(), 'quantity' => 2]],
        ]));

        self::assertResponseStatusCodeSame(201);
        self::assertResponseHasHeader('Location');
    }

    public function test_invalid_payload_returns_422_problem_json(): void
    {
        $client = static::createClient();
        $client->request('POST', '/api/orders', content: json_encode(['customerEmail' => 'not-an-email']));

        self::assertResponseStatusCodeSame(422);
        self::assertResponseHeaderSame('Content-Type', 'application/problem+json');
    }
}

The test database

  • A separate DB for test (.env.test / DATABASE_URL); never run tests against dev/prod data.
  • Reset state between tests with DAMA\DoctrineTestBundle (wraps each test in a transaction and rolls back) — far faster than truncating.
  • Build schema from migrations in CI so tests catch migration drift.
bash
php bin/console --env=test doctrine:database:create
php bin/console --env=test doctrine:migrations:migrate --no-interaction

Fixtures via factories (Foundry / Zenstruck)

Prefer zenstruck/foundry factories over static fixture files — readable, overridable per test, no shared mutable state.

php
final class OrderFactory extends PersistentProxyObjectFactory
{
    public static function class(): string { return Order::class; }

    protected function defaults(): array
    {
        return [
            'customerEmail' => self::faker()->email(),
            'status' => OrderStatus::Pending,
        ];
    }
}

// In a test
$order = OrderFactory::createOne(['status' => OrderStatus::Active]);
OrderFactory::createMany(5);

Conventions

  • Name tests by behavior: test_confirming_an_empty_order_is_rejected, not testConfirm.
  • Arrange / Act / Assert structure; one logical assertion target per test.
  • Don't assert on private internals — test observable behavior.
  • Keep functional tests few and focused on contracts; push logic coverage down to unit tests.
  • No network calls in tests — mock HTTP clients (MockHttpClient).

Gotchas

  • Agent writes everything as WebTestCase — invert back to a pyramid: most logic in fast unit tests.
  • Agent mocks the entity / value object under test — only mock injected ports/collaborators.
  • Agent hits dev/prod DB or shares state across tests — use a test DB + DAMA transaction rollback.
  • Agent builds the test schema with schema:update — run migrations so tests catch drift.
  • Agent makes real HTTP/API calls in tests — use MockHttpClient.
  • Agent writes brittle assertions on serialized internals — assert status codes, headers, and visible fields.
  • Agent uses static SQL fixture dumps — use Foundry factories for readable, isolated data.
  • Agent forgets to assert the application/problem+json content type on error-path tests.

Domande frequenti

Cosa fa la skill IA Testing Pyramid?

Usa questa skill per scrivere test per un’app Symfony: test unitari, di integrazione (Kernel) e funzionali (WebTestCase), database di test, fixture/factory (Foundry) e cosa simulare. Usala quando l’attività riguarda test, PHPUnit, WebTestCase, KernelTestCase, fixture o copertura del codice.

Perché usare Testing Pyramid su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Testing Pyramid è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Testing Pyramid in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/fatonh/symfony-skills/tree/main/skills/testing-pyramid. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Testing Pyramid?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Testing Pyramid?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Testing Pyramid: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Testing Pyramid è gratuita?

Sì. È pubblicata su GitHub da fatonh con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇