microcks / microcks/microcks-cli
feat: add JUnit XML output format and --output-file flag for CI/CD test reporting
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 52
- Fork
- 68
- Merge medio
- 6h 54m
- PR unite (30g)
- 10
Descrizione
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_resultsuses JUnit XML
Currently microcks test only outputs to stdout. There is no way to :
- Write results to a file for artifact upload or downstream tooling
- 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 :
--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
- 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:
- 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
}
- 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
}
- 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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in cmd/test.go e rivedi l’interfaccia Formatter di pkg/output da #371 prima di scegliere i punti di integrazione. Definisci le strutture JUnit in pkg/output usando encoding/xml di Go, supporta --output-file per l’output del formatter e verifica che il comportamento predefinito di stdout rimanga invariato, mentre i file JSON e JUnit contengano i risultati attesi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- cli, testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 55/100