7

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?

sth
  • 222,467
  • 53
  • 283
  • 367
toddk
  • 873
  • 1
  • 11
  • 20

4 Answers4

3

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

wst
  • 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
  • 1
    Not 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
1

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.

Oliver Hallam
  • 4,242
  • 1
  • 24
  • 30
0

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.

Pete
  • 16,534
  • 9
  • 40
  • 54
0

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.

  1. design a Test-Case Xml by having all details capture

    1. test-data ( input & expected result )
    2. test-case id
    3. test-case local methods
  2. invoke dynamically based on the details.

functions

sample test script

results

kadalamittai
  • 2,076
  • 1
  • 16
  • 19