Menu

Request for new feature for tests: isSkipped

2005-05-31
2013-04-25
  • Craeg Strong, Ariel Partners LLC

    Hello:
    We are using sqlunit to implement an extensive suite of tests for data integrity and other conditions.  We are adding custom tags so that we can organize our tests and run them in different ways.  For example, we might want to run all the tests that:
    a) are severity level warning or higher
    b) refer to reference data (not base data or configuration or security data)
    c) correspond to one or more particular named business rule(s).

    etc.  The point is that we combine these tags in arbitrary combinations to "classify" tests, and then run ant passing in tags to indicate the classifications for the tests you want to be run.

    We can add support for our custom tags by extending IHandler.  No worries there.  The description was only to provide context for my real request, below:

    I would like to request a feature for sqlunit: the ability to skip a test.

    You could either skip a test directly in XML or programmatically:

    <test>
    ...
      <skipped>true</skipped>
    ...
    </test>

    this is handy especially if you generate test.xml files from XSLT or use Ant properties:

      <skipped>${shouldSkip}</skipped>

    The "skipped" property would be a standard Java property of a test, so you could set it programmatically from a custom Handler or whatnot.

    This makes the implementation of our IHandler subclass trivial, b/c it simply tests for the presence of particular attributes and if not present, it does:

       myTest.setSkipped(true);

    We have implemented this in our local copy of the sqlunit source code, but wanted to recommend it to you since it seems like a generally useful thing to have when your test suites get very large.

    During implementation we noticed that each test returns an instance of DBResult.   For skipped tests, you could either create a "SkippedResult" that is a (trivial) subclass of DBResult, or alternatively modify slightly the sqlunit engine so it expects a Result of which a DBResult is (usually) the subclass we get.  Assuming you agree this is a good idea in the first place :-) please advise as to the approach you prefer and we can provide a patch as appropriate.

    Thanks!

    --Craeg

     
    • Sujit Pal

      Sujit Pal - 2005-05-31

      Hi Craeg,

      This is an excellent idea. My preference would be to modify the sqlunit engine so when it sees a test with the skipped child tag (my preference would have been a skip attribute, but I dont want you to have to change too many things, the preference is more cosmetic than anything else), it should just ignore the test and report it (so it adds to the skipped counter).

      The skipped tag should be optional, ie not specifying skipped will default it to false, ie the test should get executed, to maintain backward compatibility.

      And since skipped is an element by itself, it should have its own handler, even though the process() is going to be super-trivial (another reason for my wanting a skip attribute :-)).

      Thanks in advance to the patch.

      -sujit

       
      • Craeg Strong, Ariel Partners LLC

        <skip> makes sense; more compact!
        I will see what we can put together.
        What is the best way to send the patch?

         
        • Sujit Pal

          Sujit Pal - 2005-06-01

          You can send me a patch as a diff from the latest version in cvs, like so:

          cvs diff -up > /path/to/patchfile.patch

          -sujit

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.