Receber por email
← Voltar para o catálogo

create-unit-test

Create and run unit tests following the project's architecture and guidelines (Robolectric, naming, location).

367estrelas
Atualizado há 4 meses

Ver no GitHub ↗

Como adicionar

/plugin marketplace add aiskillstore/marketplace

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/create-unit-test/svg)](https://www.skillteca.com.br/skills/create-unit-test)

Skills relacionadas

Ver todas de Segurança →

Alerta por categoria

Receba novas skills de Segurança toda segunda

1 email curto, só com as skills novas de Segurança. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Create Unit Test

This skill guides the creation of unit tests to ensuring consistency and correctness.

Workflow

  1. Analyze and Plan:
  2. Goal: Understand what needs testing.
  3. Action: Examine the source code.
  4. Action: Identify "happy path" cases (core functionality).
  5. Action: Identify "error cases" and "edge cases" based on likelihood.
  6. Action: Do not suggest implementation details unless asked; focus on behavior.
  1. Setup Test File:
  2. Naming: [OriginalClassName]Test.kt.
  3. Location: [module]/src/test/java/[package/path]/.
  4. Runner: If testing Android components, you MUST use Robolectric.
  5. Mocking: Prefer creating Fakes over Mocks or patches. Use Mocks only if Fakes are too complex.
  1. Implement Tests:
  2. Write clear, descriptive test methods.
  3. Follow the "Arrange-Act-Assert" pattern.
  4. Ensure all resources (strings, themes) are properly mocked or provided via Robolectric.
  1. Run Tests:
  2. Command: ./gradlew :[module]:testDebugUnitTest
  3. Example: ./gradlew :database:testDebugUnitTest
  4. Tip: Before any commit, run ./gradlew testDebugUnitTest to ensure everything passes.
  1. Handle Failures:
  2. Goal: Diagnose and fix issues.
  3. Action: If a test fails, locate the full error report.
  4. Path: [module]/build/test-results/testDebugUnitTest/TEST-[package.name.TestClassName].xml.
  5. Example: app/build/test-results/testDebugUnitTest/TEST-com.anysoftkeyboard.janus.app.MainActivityTest.xml.

Guidelines

  • Consistency: Always place tests in the test source set, not androidTest (unless specifically writing instrumentation tests, which is rare for this skill).
  • Reliability: Avoid flaky tests. Ensure deterministic behavior.
Compartilhar X LinkedIn