You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user implementing the markdown-link-check in CI pipelines, it's helpful to have additional reporters like JUnit/XUnit to easily report on. The #364 PR addresses the JUnit reporter as additional option to the CLI, but this was later reverted.
Now I have to fallback to using regex and some PowerShell and convert it myself:
# Simple regex$successPattern= [regex]::new('\[✓\] (http[^\s]+)')
$deadPattern= [regex]::new('\[✖\] (http[^\s]+) → Status: (\d+)')
# Do transformation on content generated and then use the following function to generate JUnitfunctionConvertTo-JUnitXml {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[psobject[]]$InputObject
)
# Create XML document$xml=New-Object System.Xml.XmlDocument
$xmlDeclaration=$xml.CreateXmlDeclaration("1.0","UTF-8",$null)
$xml.AppendChild($xmlDeclaration) |Out-Null# Create root element$root=$xml.CreateElement("testsuites")
$root.SetAttribute("name","Test run")
$root.SetAttribute("tests",$InputObject.Count.ToString())
$root.SetAttribute("failures", ($InputObject|Where-Object { $_.Status-eq'Failure' }).Count.ToString())
$root.SetAttribute("errors","0")
$root.SetAttribute("skipped","0")
$root.SetAttribute("assertions","0")
$root.SetAttribute("time","0")
$root.SetAttribute("timestamp", (Get-Date).ToString("yyyy-MM-ddTHH:mm:ss"))
$xml.AppendChild($root) |Out-Null# Create a testsuite element$testsuite=$xml.CreateElement("testsuite")
$testsuite.SetAttribute("name","Brokenlink.Assertion")
$testsuite.SetAttribute("time","0")
$root.AppendChild($testsuite) |Out-Nullforeach ($itemin$InputObject) {
$testcase=$xml.CreateElement("testcase")
$testcase.SetAttribute("classname",$item.URL)
$testcase.SetAttribute("name",$item.URL)
$testcase.SetAttribute("time","0")
if ($item.Status-eq'Failure') {
$failure=$xml.CreateElement("failure")
$failure.SetAttribute("message","Status Code: $($Item.StatusCode)")
$failure.SetAttribute("type","BrokenlinkError")
$testcase.AppendChild($failure) |Out-Null
}
$testsuite.AppendChild($testcase) |Out-Null
}
return$xml.OuterXml
}
The text was updated successfully, but these errors were encountered:
As a user implementing the
markdown-link-check
in CI pipelines, it's helpful to have additional reporters like JUnit/XUnit to easily report on. The #364 PR addresses the JUnit reporter as additional option to the CLI, but this was later reverted.Now I have to fallback to using regex and some PowerShell and convert it myself:
The text was updated successfully, but these errors were encountered: