Menu

SQLUnit reports success in some failure cases

2006-03-24
2013-04-25
  • Andreas Kutschera

    Hi,
    due to a mistake in my environment I forgot to
    include the JDBC-jar file in my class path.
    But all my SQLUnit tests passed!
    It seems that SQLUnit.java catches an
    SQLUnitException that says
    "Cannot build Connection (connection-id=1) because com.mysql.jdbc.Driver not found in specified Context"
    which is okay.
    It does not add to the result-failureCount, however.
    Therefore the 'finally' branch in SQLUnit.processDoc calls reporter.testFileComplete with a success parameter of "true".
    Before I look at it further and try to build a
    patch, is this the desired behaviour?
    I would expect my test to fail if SQLUnit cannot even load a needed class file.
    --
      Andreas

     
    • Sujit Pal

      Sujit Pal - 2006-03-25

      Hi Andreas,

      SQLUnit considers the connection part almost like setUp() in JUnit, so there is no concept of failure as there is in within a test. So this is not a failure case.

      However, not having the driver in the classpath is likely to blow up all subsequent tests with a null pointer exception, so my suggestion for your patch would be to throw an exception and halt immediately, ie dont bother running subsequent tests.

      TIA for the patch,
      Sujit

       
    • Andreas Kutschera

      Okay, patch submitted.
      I noticed that ConnectionFactory catches the
      ClassNotFoundException and throws an
      SQLUnitException instead.
      All the SQLUnitExceptions I looked at seem
      to indicate that the test(s) failed, so I
      submitted a very simple patch.
      This will blow up if SQLUnitExceptions turn out
      to be either 'failure' or 'non-failure'.
      Then I will have to look at it more closely.
      Hope this works (the patch looks too simple to
      be good :-).
        Andreas

       
    • Sujit Pal

      Sujit Pal - 2006-04-05

      Hi Andreas,

      I think you may have forgotten to attach the patch file. I've updated the 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.