I've been working with a document repository using XQuery (via Java and .NET interfaces) and was wondering if anyone has any recommendations for unit testing XQuery modules?
4 Answers
There are several XQuery unit testing frameworks, but most are special-purpose written for a specific XQuery Processor. This is not a complete list, but includes most of the popular ones I'm aware of:
MarkLogic
Roxy Unit Tester https://github.com/marklogic/roxy/wiki/Unit-Testing
XQUT https://github.com/mblakele/xqut
xray https://github.com/robwhitby/xray
eXist
XQSuite http://exist-db.org/exist/apps/doc/xqsuite.xml
BaseX
XQuery Unit Module http://docs.basex.org/wiki/Unit_Module

- 11,681
- 1
- 24
- 39
-
There is also XSuite which lets you run XQSuite tests as JUnit tests – adamretter Aug 26 '18 at 09:24
-
@adamretter, is there documentation for XSuite? I only see it mentioned in eXist release notes. – wst Aug 26 '18 at 23:03
-
1Not exactly. XSpec javadoc can be seen here: https://github.com/eXist-db/exist/blob/develop/test/src/org/exist/test/runner/XSuite.java#L46 One of many examples of it being used can be seen here: https://github.com/eXist-db/exist/blob/develop/test/src/xquery/dates/DateTests.java#L28 Let me know if you need more info on XSuite... – adamretter Aug 27 '18 at 18:38
Here is a quick DIY type solution for this problem:
Poor man's unit testing with XQuery (dead link).
This approach seems to have been embraced and extended for the tests of the xprocxq project.
Other tools exist, for example XTC.

- 4,242
- 1
- 24
- 30
Try XQSuite
It's pretty slick; here's the "minimal example":
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare function %test:assertEquals("Hello world") local:hello() {
"Hello world"
};
Additionally, XSpec works wonderfully for XSLT testing (provides nicely formatted HTML test results, for example) BUT appears to need a bit of work with XQuery testing. The project appears to have become inactive in the past few years.

- 16,534
- 9
- 40
- 54
This link may spruce your development. This is just an idea but you can develope and enhance more on this with various unit-test case design ideas.
since Xml is a king in meta-data world its quite easy to design and run.
design a Test-Case Xml by having all details capture
- test-data ( input & expected result )
- test-case id
- test-case local methods
invoke dynamically based on the details.

- 2,076
- 1
- 16
- 19