2017-03-06 7 views
0

私はxqファイルを呼び出すだけで実行できるライブラリモジュールを書くのが好きです。しかし、これらにはテストしたい機能も含まれています。このsome.xqlような何か:その中から何か機能:私は、モジュール全体、あるいはまったくをテストすることはできませんしかしexist-db内のライブラリモジュールにxqsuiteを使用

xquery version "3.0"; 
import module namespace xmldb="http://exist-db.org/xquery/xmldb"; 
declare namespace no="http://none"; 
declare namespace test="http://exist-db.org/xquery/xqsuite"; 

declare 
    %test:arg('1') 
    %test:assertEquals('2') 
    function no:something ($num as xs:string?) as xs:string { 
    return 
      $num + 1 
}; 

xmldb:store('/db/data/', 'two.xml',<root>{no:something(1)}</root>) 

。私はxpty00004エラーを得続けるラッパー関数からテストスイートを実行しようとしたときしかし

import module namespace no="http://none" at "some.xql";

、::私は使用して他のコンテキスト内の関数にアクセスする問題がない

xquery version "3.0"; 
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"; 
test:suite(
    inspect:module-functions(xs:anyURI("some.xql")) 
) 

私は別の試してみましたno:some機能に到達するまでの変化はありますが、ロックはありません。 xqsuiteを間違って使って、本当に悪いクエリを書いているのですか、これはバグですか?あなたのsome.xql

答えて

2

は、メインモジュールであることができますライブラリモジュールで唯一のインポートおよびテスト機能。

no.xqmのようなライブラリモジュールにリファクタリングする代わりに考えてみましょう:

xquery version "3.0"; 

module namespace no="http://none"; 

declare namespace test="http://exist-db.org/xquery/xqsuite"; 

declare 
    %test:arg('1') 
    %test:assertEquals('2') 
function no:something ($num as xs:string?) as xs:string { 
    $num + 1 
}; 

アプリメインモジュールsome.xq

xquery version "3.0"; 

import module namespace no="http://none" at "no.xqm"; 

xmldb:store('/db/data/', 'two.xml',<root>{no:something(1)}</root> 

あなたのテストランナーメインモジュールtests.xq

xquery version "3.0"; 
import module namespace test="http://exist-db.org/xquery/xqsuite" 
at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"; 

test:suite(
    inspect:module-functions(xs:anyURI("no.xqm")) 
) 
+0

を私は恐れていましたこれが事実です。しかし、今私は知っている。詳細な答えをありがとう。 – duncdrum

関連する問題