marklogic-community / roxy

Deployment tool for MarkLogic applications. Also provides optional unit test and XQuery MVC structure
Other
87 stars 66 forks source link

Endpoint to Generate Full XUnit Report #860

Open rjkennedy98 opened 6 years ago

rjkennedy98 commented 6 years ago

Endpoint to Generate Full XUnit Report

Add endpoint for generating full xunit report

I see there is a function "run" that can generate an xunit report for a suite, but I don't see an endpoint for generating a full xunit report.

declare function local:run-all() {

  let $all-tests := 
      for $suite-xml in t:list()/t:suite
          let $suite as xs:string* := $suite-xml/@path
          let $tests := ()
          let $run-suite-teardown as xs:boolean := xdmp:get-request-field("runsuiteteardown", "") eq "true"
          let $run-teardown as xs:boolean := xdmp:get-request-field("runteardown", "") eq "true"
          return
              let $result := t:run-suite($suite, $tests, $run-suite-teardown, $run-teardown)
              return local:format-junit($result)
    return (
    xdmp:set-response-content-type("application/xml"),
    <test-suites errors="{fn:sum($all-tests/xs:integer(@errors))}" failures="{fn:sum($all-tests/xs:integer(@failures))}" hostname="{($all-tests/@hostname)[1]}" tests="{fn:sum($all-tests/xs:integer(@tests))}" time="{fn:sum($all-tests/xs:decimal(@time))}">
        {
        $all-tests
        }
    </test-suites>
    )
};

If that function is added then a full xunit report can be created by invoking: hostname:port/test/default.xqy?func=run-all