exp-test-maintainability
O que ela faz
Esta skill revisa o código de testes .NET em busca de configurações, asserções e métodos de teste repetidos copiados e colados, depois sugere como organizá-los. É para desenvolvedores cujos projetos de teste cresceram de forma bagunçada e repetitiva.
Quando usar
- ✓Quando seus arquivos de teste repetem a mesma configuração ou as mesmas asserções muitas vezes.
- ✓Quando muitos métodos de teste parecidos poderiam virar um único teste orientado a dados.
- ✓Quando você quer ideias de refatoração para uma suíte de testes sem alterá-la ainda.
Link da skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-experimental/skills/exp-test-maintainability/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Encontre a configuração duplicada e os testes copiados e colados no meu projeto de testes de pagamentos e sugira uma estrutura mais limpa.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente lê os arquivos de teste e, quando útil, o código testado, depois informa os padrões repetidos com sugestões de antes e depois. Ele não altera os arquivos.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Test Maintainability Assessment
Analyze .NET test code for maintainability issues: duplicated boilerplate, copy-paste test methods, and structural repetition across test methods and classes. Produce a report of refactoring opportunities with concrete before/after suggestions. The goal is analysis only — do not modify any files.
When to Use
- User asks to find duplicated code or boilerplate in tests
- User wants to know where test code can be DRY-ed up
- User asks to reduce test duplication, improve test readability, or clean up test boilerplate
- User asks for refactoring opportunities in a test suite
- User wants to identify shared setup or teardown candidates
- User asks "what patterns repeat across my tests?"
- User wants to centralize test data, introduce builders or helpers
When Not to Use
- User wants to write new tests from scratch (use
writing-mstest-tests) - User wants to detect anti-patterns or code smells (use
test-anti-patterns) - User wants to actually perform the refactoring (help them directly, this skill only analyzes)
Inputs
| Input | Required | Description |
|---|---|---|
| Test code | Yes | One or more test files or a test project directory to analyze |
| Production code | No | The code under test, for context on what abstractions might help |
| Scope | No | Whether to analyze within a single class or across multiple classes |
Workflow
Step 1: Gather the test code
Read all test files the user provides or references. If the user points to a directory or project, scan for all test files using these framework markers:
| Framework | Test class markers | Test method markers |
|---|---|---|
| MSTest | [TestClass] |
[TestMethod], [DataTestMethod] |
| xUnit | (none — convention-based) | [Fact], [Theory] |
| NUnit | [TestFixture] |
[Test], [TestCase], [TestCaseSource] |
| TUnit | (none — convention-based) | [Test] |
Step 2: Identify maintainability issues
Scan for these categories:
Category 1: Repeated object construction
Look for the same object being constructed in 3+ test methods with identical or near-identical parameters.
Indicators:
new ClassName(...)appearing with identical arguments in multiple tests- Multiple tests creating the same "system under test" with similar configuration
- Repeated mock/fake/stub creation with the same setup
Potential refactorings:
- Extract a factory method or test helper (e.g.,
CreateSut(),CreateDefaultOrder()) - Use
[TestInitialize]/constructor/[SetUp]for shared construction - Introduce a builder pattern for complex objects with many variations
Example — before:
[TestMethod]
public void Process_ValidOrder_Succeeds()
{
var logger = new FakeLogger();
var email = new FakeEmailService();
var inventory = new FakeInventory(stock: 100);
var processor = new OrderProcessor(logger, email, inventory);
// ...
}
[TestMethod]
public void Process_EmptyItems_Fails()
{
var logger = new FakeLogger();
var email = new FakeEmailService();
var inventory = new FakeInventory(stock: 100);
var processor = new OrderProcessor(logger, email, inventory);
// ...
}
After — extract factory:
private static OrderProcessor CreateProcessor(int stock = 100)
{
return new OrderProcessor(new FakeLogger(), new FakeEmailService(), new FakeInventory(stock));
}
Category 2: Repeated assertion patterns
Look for the same sequence of assertions appearing in 3+ test methods.
Indicators:
- Multiple tests asserting the same set of properties on a result object
- Repeated null-check-then-value-check sequences
- Same collection of
Assert.AreEqualcalls across methods
Potential refactorings:
- Extract a custom assertion helper (e.g.,
AssertValidOrder(order, expectedTotal, expectedStatus)) - Use framework-specific assertion extensions
- Introduce a
Verifymethod that checks a standard set of properties
Category 3: Copy-paste test methods
Look for test methods with near-identical bodies differing only in input values or a single parameter.
Indicators:
- 3+ methods with the same structure but different literal values
- Methods that could be collapsed into
[DataRow]/[Theory]/[TestCase] - Test names that follow a pattern like
Method_Input1_Result,Method_Input2_Result
Potential refactorings:
- Convert to parameterized tests with
[DataRow]/`
Perguntas frequentes
Ela muda meus arquivos de teste?
Não. É apenas para análise, e ela informa sugestões que você pode escolher aplicar.
Ela pode sugerir testes parametrizados?
Sim. Pode sugerir transformar testes copiados e colados em testes orientados a dados.
Ela escreve testes novos?
Não. Para escrever testes novos, é usada outra skill.
Detalhes
Descrição original do autor
Detects duplicate boilerplate, copy-paste tests, and structural maintainability issues across .NET test suites. Use when the user asks to reduce repetition, consolidate similar test methods, convert copy-paste tests to data-driven parameterized tests, suggest a better test structure, or identify refactoring opportunities. Identifies repeated construction, assertion patterns, copy-paste methods convertible to DataRow/Theory/TestCase, redundant setup/teardown, and shared infrastructure. Produces an analysis report with concrete before/after suggestions. Works with MSTest, xUnit, NUnit, and TUnit
repo: dotnet/skills
Popularidade
- Estrelas no GitHub
- 5,8 mil
- Posição no ranking
- #14581
- Licença
- MIT
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
create-custom-agent
5,8 milAjuda seu agente a criar arquivos de agentes personalizados para o VS Code, com suas próprias ferramentas, instruções e transferências para outros agentes.
create-skill
5,8 milAjuda seu agente a criar uma nova skill de agente com nome válido, uma descrição clara de quando usá-la e um arquivo SKILL.md que segue o padrão.
csharp-scripts
5,8 milAjuda seu agente a rodar um pequeno programa C# como um único arquivo com a ferramenta de linha de comando do .NET, sem criar um projeto completo.
dotnet-pinvoke
5,8 milAjuda seu agente a chamar corretamente bibliotecas nativas em C ou C++ a partir do .NET, cobrindo assinaturas, tratamento de strings, memória e handles seguros.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.