Unit Testing XQuery
Asked Answered
A

4

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?

Adige answered 4/2, 2009 at 23:32 Comment(0)
C
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.

Clubfoot answered 10/2, 2009 at 23:1 Comment(0)
A
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

Aloysius answered 15/10, 2013 at 19:7 Comment(4)
There is also XSuite which lets you run XQSuite tests as JUnit testsMicco
@adamretter, is there documentation for XSuite? I only see it mentioned in eXist release notes.Aloysius
Not exactly. XSpec javadoc can be seen here: github.com/eXist-db/exist/blob/develop/test/src/org/exist/test/… One of many examples of it being used can be seen here: github.com/eXist-db/exist/blob/develop/test/src/xquery/dates/… Let me know if you need more info on XSuite...Micco
The Roxy repo now has a banner that says "This repository has been archived by the owner on Nov 9, 2022. It is now read-only." MarkLogic-unit-test github.com/marklogic-community/marklogic-unit-test looks like a replacement.Arela
C
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.

Clubfoot answered 10/2, 2009 at 23:1 Comment(0)
M
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

Metalanguage answered 5/8, 2010 at 15:44 Comment(0)
L
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.

Lepidopterous answered 15/10, 2013 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.