Menu

Question on how reporters are called

2005-06-08
2013-04-25
  • Ivan Ivanov

    Ivan Ivanov - 2005-06-08

    Hello Sujit,

    I started to wrote my own reporter and I have a question about the way SQLUnit framework calls its reporters.
    In net.sourceforge.sqlunit.SQLUnit around line 320, we see that the reporter's runningTest() method is invoked:
    reporter.runningTest(elTest.getName(), testIndex,
          elTest.getAttributeValue("name"));

    I wonder why the first argument is elTest.getName(). This is the name of the test XML tag and thus it is always "test". Moreover, the IReporter's javadoc for this method says that the first argument " the name of the test being run" and not the name of the XML tag.
    The same holds for calling IReporter.skippedTest().

    I think the name of the test is the content of the test's name attribute:
    <test name="MyTest">...</test>, so I think runningTest() and skippedTest() should be called with elTest.getAttributeValue("name") as their first argument, and the thirdArgument should be left for some kind of description (like why the test is skipped), not for the test's name.

    What I also can suggest is to add the ability to attach several reporters to the SQLUnit process so that the user can log on several places, for example on the console and in a file. This is like ant's <junit> task formatters and the idea can be extended to sqlunit task:
    <sqlunit>
       <fileset dir ="..."></fileset>
       <reporter name="default"/>
       <reporter name="canoo"/>
    </sqlunit>

    Regards
    Ivan Ivanov

     
    • Sujit Pal

      Sujit Pal - 2005-06-08

      Hi Ivan,

      Actually, the name of the element tells me the type of test action. So test is just one kind of test, there are others such as batchtest and diff and also echo, although thats not really a "test" action.

      I will be trying to add in the skip and classifiers functionlaity to these as well.

      The multiple reporter idea is great, we can do that quite easily, it just pulls multiple IReporter objects out of the factory. Perhaps SQLUnit should use "wrapper" methods which iterate through the list of IReporters.

      -sujit

       
    • Sujit Pal

      Sujit Pal - 2005-06-10

      Hi Ivan,

      I was looking at the code for doing multiple reporters, and I think we need to put in the logfile name for each reporter output file as well, so perhaps:
      <sqlunit>
      <fileset dir ="..."></fileset>
      <reporter format="default" file="sqlunit-output.txt" />
      <reporter format="canoo" file="sqlunit-output.xml" />
      </sqlunit>

      I would prefer to keep the name close to the old attribute(s) so people are minimally confused. I am pretty much not going to be anywhere near a computer for the next 3 weeks, so if you want, and especially considering your experience with Ant development, you may be the best person to get this out quickly. Only if you want to, of course, otherwise I can do this when I get back.

      If you do, post the updated Ant task with some information about how to use it in the Patches section (see links above), you can upload files there, and let people know on this forum, so they can copy it over the one that comes with the distribution and give it a try.

      It probably should not be too hard (although I am speaking from fairly limited experience with building Ant tasks, I have done only two, this one and another to do jsp compilation for resin, used internally where I work). I think we would need a Reporter object with format and file attributes and a addReporter() method in the SqlUnitAntTask.

      TIA
      -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.