Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

feat: add JUnit XML output format and --output-file flag for CI/CD test reporting

Aberta
#386 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
55/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
go
Domínio
cli, testing

Direção de pesquisa

Comece em cmd/test.go e revise a interface Formatter de pkg/output de #371 antes de escolher os pontos de integração. Defina as estruturas JUnit em pkg/output usando encoding/xml do Go, ofereça suporte a --output-file para a saída do formatter e verifique se o comportamento padrão de stdout permanece inalterado, enquanto os arquivos JSON e JUnit contêm os resultados esperados.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Context:
Maintainer @Harsh4902 raised in #301: "can we store this output at a particular location for further usage?" — this issue directly addresses that question.

CI/CD platforms natively consume JUnit XML for test reporting:

  • GitHub Actions: renders test results in PR summaries via junit-reporter
  • Jenkins: JUnit plugin reads XML natively, no extra config
  • GitLab CI: artifacts: reports: junit: picks it up automatically
  • CircleCI: store_test_results uses JUnit XML

Currently microcks test only outputs to stdout. There is no way to :

  1. Write results to a file for artifact upload or downstream tooling
  2. Produce JUnit XML that CI dashboards can render natively

This forces teams to parse text output with fragile regex, defeating the purpose of structured CI integration.

Description :
Two additive features, cleanly separated :

  1. --output-file=<path> flag
    Write test results to a file instead of (or in addition to) stdout.
    Enables GitHub Actions artifact uploads, local file caching, and script pipelines without output redirection hacks.
microcks test ... --output json --output-file results.json
microcks test ... --output junit --output-file results.xml
  1. junit output format
    A new format value for the --output flag (building on #371's pkg/output Formatter interface) :

Non-breaking: both flags are opt-in. Default behavior (text to stdout) unchanged.
Builds on #371: reuses the pkg/output Formatter interface — JUnit is just another Formatter implementation.

Implementation ideas:

  1. Add --output-file= to cmd/test.go — open the file, pass an io.Writer to the formatter :

var out io.Writer = os.Stdout
if outputFile != "" {
f, err := os.Create(outputFile)
if err != nil { ... }
defer f.Close()
out = f
}

  1. Add JUnitFormatter to pkg/output/ implementing the Formatter interface from #371:

type JUnitFormatter struct{}

func (f *JUnitFormatter) Format(result *TestResult, w io.Writer) error {
// marshal to encoding/xml JUnit structs
}

  1. JUnit XML structs (stdlib encoding/xml — zero new dependencies) :

type JUnitTestSuites struct {
XMLName xml.Name xml:"testsuites"
Suites []JUnitTestSuite xml:"testsuite"
}
type JUnitTestSuite struct {
Name string xml:"name,attr"
Tests int xml:"tests,attr"
Failures int xml:"failures,attr"
Cases []JUnitTestCase xml:"testcase"
}

no new dependencies — uses only stdlib encoding/xml.

happy to implement once the pkg/output foundation from #371 lands.

Linguagem predominante
Go
Estrelas
59
Forks
74
Merge médio
4d 8h
PRs com merge (30d)
23

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microcks/microcks-cli

Todas as issues de microcks/microcks-cli

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.