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?
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
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.
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.
functions
sample test script
results
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.
Related
I need an example of well-structured full-stack GWT application written in the best practices: with MVP pattern usage, GIN modules (at least 2: production module and the mocking one for tests), JRE light-weight tests (extending TestCase class). The primary goal of this request is to find out how GWT app should be effectively tested with the help of GIN.
This showcase doesn't need to be huge. Several simple tests for one presenter would be enough. I have already took a look at "Contacts" example provided by Google - but it doesn't use GIN library.
Thanks a lot for any advance.
The apache Hupa project http://james.apache.org/hupa/ build with GWT uses Gin/Guice, mocking and the MVP pattern.
Try this link:
http://www.aceevo.com/
It does use GIN, but for me it covers a big spectrum of things to consider.
I'm still working on the whole MVP thingy trying to put everything together.
However, there are some tweaks before this example is runnable. If you someone thinks it's worth it I would post those tweaks.
In most framework unit testing implementations, you have a set of a tests and you execute those tests from a single [console] command. The tests run and a result is given. That result varies but generally it includes pass / fail.
CodeIgniter’s unit testing framework appears different and I have noticed an extensive collection of random tack-on-projects to either enhance or replace the CodeIgniter unit testing framework.
My question is this: What is the intended work flow or use of the unit testing framework built in to CodeIgniter?
I read the documentation; I get it. It’s a simple class. But where does one utilize the class?
For example, do all the tests go in to a single “test” controller? Or do the tests get intermingled in to each controller? Then there is the question of the models and custom helpers... Also, I'm assuming tests are run via a browser (or the alike) request...
Thanks for the guidance!
Regards,
Frank
I've received an answer from another source and I want to post it here since I am aware of it.
The basic answer is that the CI (CodeIgniter) unit test class is not intended like a traditional unit test suite (JUnit, NUnit, or python's unittest). In CI, the class is intended to be used within the target (the testing target's code base).
To be clear: I'm not endorsing this nor am I sure this is the intended use of the CI unit_test class. This is just what I was told thus far. Perhaps others heard this too and can vote it up. If this is voted up or has support via comments, I'll mark this as an answer. I am still interested in differing opinions.
does anybody have any experience writing unit tests for sql server 2000 DTS packages?
I about to start working with DTS and jobs, so I want to be able to unit test as much as possible. I guess i could invoke dtsrun.exe via command line , but perhaps someone else has better ideas.
Thanks
Fede
I came here looking for insight but since no one else has given you ideas, I did come up with one that I will share.
In my case (I know not all cases), we use a lot of ActiveX (VBScript) scripts to accomplish things. I'm theorizing (I've not tried this) that, if I move my ActiveX functionality to VBScript classes that I can unit test those classes and etc. and then do very, very basic class instantiation and usage in the main function of the ActiveX script.
I've not tried to implement this; my project does not have the budget to do so. But, in theory it seems sound. I also am unaware of any challenges this may cause.
Please see another question I posted here. The question is loosely related to yours. The answer I selected for this question doesn't fit your scenario. You'd be more interested in Michal's answer: Creating unit tests for your asp application
Saw this question had been here for a while so I'm just throwing some ideas out there...
I'm wondering if you could write some code to use the DTS API to call your packages, then write assertions about those packages in the unit test tool for whatever language you used. For example, you could write your code in C# and use NUnit.
Additionally, if your DTS packages are all just calling SQL stored procedures, you can unit test the procedures (which would be true unit testing) using T-SQL Unit.
If it's higher level (integration) tests you want, then you might also consider hooking FitNesse up to the DTS API.
Not sure if any of this helps, but I hope I've at least given you some ideas.
Does anyone know if there exists something like XMLUnit for C++? I'm looking for an easy way to check nodes, values, etc in a XML output. We are using Google test in Visual Studio but I suppose any library that makes the work easier will be enough.
I'm using Xerces as an XML parser but XMLUnit (http://xmlunit.sourceforge.net/) has some features wrapped over the XML parser that are very useful for unit testing. For example, asserts using XPath expressions, functions to compare two "similar" XMLs, etc.
I have used a combination of Xerces and CPPUnit to accomplish this in the past. In my test cases I would create a DOM object with the Xerces API in the setUp() function. This DOM would represent my expected results. In the test case itself I would then read the XML file and the class under test would populate a DOM object representing the contents of the file. To check equality I would walk through the two DOM trees via the Xerces API (DOMTreeWalker) and use CPPUnit assertions as I compared the contents of the DOM nodes. It was a bit tedious but there were no frameworks available at the time that could mimic XmlUnit. I would imagine that Google Test would work just as well as CPPUnit for accomplishing this task.
The Xerces API has some support for XPath expressions:
http://xerces.apache.org/xerces-c/faq-parse-3.html#faq-2
For validation you would need to set up an error handler as mentioned here and incorporate it into your test case:
Validating document in Xerces C++
For XSLT transform checking you would need to use Xalan. It works with Xerces so I wouldn't anticipate any major difficulties:
http://xalan.apache.org/old/xalan-c/index.html
I was not able to locate any obvious products that packaged XMLUnit-like operations in C++. So the answer is I think you will have to roll your own. Good luck.
I really like http://pugixml.org/
It:
is stable
is extremely fast
has great documentation and sample code
is licensed under the MIT license
is very STL friendly
is still quite an active project
has great support for xpath
You can use tinyxml package here: tinyxml
I'm working with it and it's quite friendly and bug free.
It's an xml handling.
I guess it wasn't designed for unit testing, but you can use it to check/test your xml files.
It as expected loads the xml into a DOM object and supplies a nice API to run on the nodes.
Gal
Xerces at http://xerces.apache.org/xerces-c/i pretty full featured, has a C++ interface and produces good error messages, which several other XML parsers don't do so well. Having said that, it's pretty big & I've wound up using my own wrapper round the C parser Expat.
I'm currently using libxml++ for a personal project of mine.
I use Boost property_tree for xml, easy to use, pretty robust and works well with Boost unit test framework.
What is currently the best tool for JavaME unit testing? I´ve never really used unit testing before (shame on me!), so learning curve is important. I would appreciate some pros and cons with your answer. :)
I think it will depend on what kind of tests are you planning to do. Will you be using continuous integration. Is running tests on handsets a must.
If tests are more logic/data processing tests, the you can do fine with JUnit. But if you need to use some classes from javax.microedition.*, then the things will become a bit tricky, but not impossible.
Some examples: a test for text wrapping on screen, that would need javax.microedition.lcdui.Font. You can't just crate a font class using jars shipped with WTK, because at initialization it will be calling some native methods, that are not available.
For these kind of tests I have created a stub implementation of J2ME. Basically these are my own interpretation of J2ME classes. I can set some preconditions there (for example every character is 5 pixels wide, etc). And it is working really great, because my test only need to know, how J2ME classes respond, not how they are internally implemented.
For networking tests I have used MicroEmulator's networking implementation, and it has also worked out well.
One more issue with unit tests - it is better to have your mobile projects as a java project using Java 4,5,6, because writing test in 1.3 is, at leas for me, a pain in the...
I belive, that starting with JUnit will be just fine, to get up and running. And if some other requirements come up (running tests on handsets), then You can explore alternatives.
I'll be honest, the only unit tester I've used in Java is JUnit and a child project for it named DBUnit for database testing... which I'm assuming you won't need under J2ME.
JUnit's pretty easy to use for unit testing, as long as your IDE supports it (Eclipse has support for JUnit built in). You just mark tests with the #Test annotation (org.junit.Test I think). You can also specify methods that should be run #Before or #After each test, as well as before or after the entire class (with #BeforeClass and #AfterClass).
I've never used JUnit under J2ME, though... I work with J2EE at work.
Never found an outstanding one. You can try to read this document :
how to use it
and here the link to : download it
Made by sony ericsson but work for any J2ME development.
And I would recommend you spend some time learning unit testing in plain Java before attacking unit testing on the mobile platform. This may be a to big to swallow one shoot.
Good luck!
There's a framework called J2MEUnit that you could give a try, but it doesn't look like it's still being actively developed:
http://j2meunit.sourceforge.net