[MarkLogic Dev General] RE: Unit testing
Geert.Josten at daidalos.nl
Thu Nov 5 08:41:39 PST 2009
If you would like to test XQuery 1.0 code, you could use any available processor you like. But if you are using MarkLogic Server specific extensions, like cts:search or more advanced, then you can only use MarkLogic Server. It won't make sense to test the use of such extensions outside the context of the database, most are designed for interaction with the database.
I am not sure what you mean by 'the tests are slower', though I reccon using XCC to connect to MarkLogic to execute each separate test query will take some overhead. There are alternatives though. I myself have used the PerformanceMeters tool that is available on xqzone (http://developer.marklogic.com/code/) for that purpose. It is actually meant for performance measurements, executing single queries many many times to calculate averages and so. I used it without the repetition part, and wrote a JUnitReporter object that can be used to generate ant-style junit xml output, that can be processed by the junit-ant extension to generate nice HTML reports. Ideal for unit and regression tests.
The fun is that the syntax of the performance-meters configuration files is easy xml, so you don't need to write a single line of Java to do testing, just embed xquery statements in the xml config file, provide a url and some credentials and you are ready to go..
I haven't committed the JUnitReporter to svn yet. I can do so if there are more people interested, otherwise I can send it personally..
Drs. G.P.H. Josten
Source of Innovation
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
> From: general-bounces at developer.marklogic.com
> [mailto:general-bounces at developer.marklogic.com] On Behalf Of
> Runstein, Robert E. (Contr) (IS)
> Sent: donderdag 5 november 2009 16:32
> To: general at developer.marklogic.com
> Subject: [MarkLogic Dev General] Unit testing
> How do you create automated tests for your modules and
> libraries? Being a firm believer in the value of unit tests,
> I leveraged some of MarkLogic's sample code to pass ad hoc
> queries to MarkLogic using Junit and asserting the expected
> results. While useful in detecting bugs, the tests are
> slower than I would like and involve more "noise" in their
> setup, tending to obscure what is being tested.
> When my code lives outside the database I avoid database
> interaction to preserve the "unit" focus of the test and keep
> the tests fast. With MarkLogic, the Xquery engine lives
> inside the database so it seems inevitable that I have to
> interact with the database (even if my logic does not read or
> write to it). Is there an Xquery engine that replicates
> MarkLogic's implementation that can be run from within an IDE
> like Eclipse or from an Ant script so that I could run test
> my modules locally? If so, I could write my custom Xquery
> code to avoid actually reading or writing to the database and
> delegate to built in functions (that could hopefully be
> stubbed out for the tests) to do the actual work.
> I've googled xqunit and not found anything active. Has
> anyone found something useful?
More information about the General