[MarkLogic Dev General] RE: Unit testing
Mark Helmstetter
Mark.Helmstetter at marklogic.com
Fri Nov 6 06:23:27 PST 2009
Bob,
Our professional services organization has a JUnit framework that we've been using on customer engagements for the last several years. My hope is that we can someday (soon) document this framework and make it available via the workshop at developer.marklogic.com. The biggest thing that's lacking right now is documentation on how it all works.
The framework depends on the server side. We typically run our tests against a local instance of MarkLogic server, running in a database that's specifically reserved for unit tests. The unit tests will typically insert some documents as part of setup(), run some tests, do some assertions, and then clean up everything in the tearDown(). While you might be able to test certain aspects of an XQuery application using an embedded XQuery engine, I don't think that would get you very far with all of the advanced capabilities and extensions of MarkLogic Server. Also, I'd think that would in many respects be defeating the purpose of the tests. You'd want your tests to exercise the target platform.
When you say that your tests are "slower", how slow are they? Minutes? 10's of seconds? Is it maybe the setup part of your tests that is slow, and you could pair down the amount of data that you're inserting for your tests.
As far as the "noise" in setting up the tests, I believe that to some degree that is unavoidable but I also think that some of the code and techniques that we've developed will help facilitate easier and less-messy testing.
--Mark
_____
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Runstein, Robert E. (Contr) (IS)
Sent: Thursday, November 05, 2009 10:32 AM
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?
Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20091106/dc8eb2f9/attachment-0001.html
More information about the General
mailing list