I have pairs of XML databases that i want to iterate through and use it as input for unit tests. I'm using BaseX Unit Testing Module. To give an example validate.xqm
looks like this:
module namespace test="mytests";
declare variable $test:fibexDB external;
declare variable $test:autosarDB external;
declare variable $test:fibex := db:open($test:fibexDB);
declare variable $test:autosar := db:open($test:autosarDB);
declare %unit:test function test:validateCountSignals() {
let $countSignalsFBX := count($test:fibex//*:SIGNAL)
let $countSignalsASR := count($test:autosar//*:SYSTEM-SIGNAL)
return unit:assert-equals($countSignalsFBX,$countSignalsASR + 5,concat('Database:',$test:fibexDB))
};
declare %unit:test function test:validateOEMExtension() {
let $countOEMExtensionsFBX := count($test:fibex//*:OEM-SPECIFIC-EXTENSIONS)
return unit:assert-equals($countOEMExtensionsFBX,1,concat('Database:',$test:fibexDB))
};
I know that the tests can be started with the TEST command or on the command line like this:
\bin\basex -oC:\UnitTestConverter\FlexRayTestResult.xml -b{mytests}fibexDB=DB01A -b{convertertests}autosarDB=DB01B -t validate.xqm
Is it also possible to start validate.xqm
in a XQuery script? Or is there any other X-technology solution that let iterate through a set of input values and start one or more unit test modules?
I've found support for this question on BaseX-Talk. Hence i undeleted the question in order to give the answer here: "It is not possible.". But you can use proc:system
and start a BaseX process for processing each test suite. I'm now using a function like this:
declare function test:runtest($database, $testmodule, $moduleid) {
let $name := $database/@name
let $args := ('-cp',$test:basexjar,'org.basex.BaseX','-b',concat('{unittest}testsuitesfile=',$test:testsuitesfile),'-b',concat('{unittest}configfile=',$test:configfile),'-b',concat('{unittest}tssid=',$test:tssid),'-b',concat('{unittest}dataid=',$database/@name),'-o',concat($test:unittestresultpath,$test:tssid,'_',$name,'_',$moduleid,'.xml'),'-t',$testmodule)
return (
try {proc:system('java',$args)} catch * { }
)
};