Loading ...
Sorry, an error occurred while loading the content.

RE: [junit] junit, dbunit and xmlunit

Expand Messages
  • Böhm, Martin
    Hi, I think it isn t a good solution to merge different APIs. First, what s your intention? Maybe you should first try to identify your test domains, for
    Message 1 of 23 , Mar 31, 2008
    • 0 Attachment
      Hi,

      I think it isn't a good solution to merge different APIs.
      First, what's your intention?

      Maybe you should first try to identify your test domains, for example
      DB-Tests, XML verfication tests and so on. Then you may create
      different base tests for the different test domains. The main draw back
      I see for a mega-testcase are the extensive dependencies to different
      resources as also apis, you may need for the different test types.

      If you really have something like versatile services that serve allmost
      anything, its helpfull to look for the services from different points
      of view: db-service, xml-service and so on. Sometimes the interfaces
      of the class under test give you a hint, what different points of
      view the class serves and what different base tests you need to test
      such a class thoroughly.

      Any further suggestions?

      > -----Original Message-----
      > From: junit@yahoogroups.com [mailto:junit@yahoogroups.com] On
      > Behalf Of Kamal
      > Sent: Montag, 31. März 2008 19:40
      > To: junit@yahoogroups.com
      > Subject: [junit] junit, dbunit and xmlunit
      >
      > How to have a framework that incorporates other API's seamlessly
      >
      > We are using JUnit for its versetile assertions - BaseTest = TestCase
      >
      > API - BaseTest Name - interface
      >
      > JUNIT - TestCase - implements public interface Test
      >
      > XMLUnit - XMLTestcase - public abstract class XMLTestCase
      > extends junit.framework.TestCase implements XSLTConstants ,
      > public interface XSLTConstants extends XMLConstants
      >
      > DBUnit - DBTestCase - implements public interface Test
      >
      > Create a RulePointBaseTest class
      >
      > RulePointBaseTest extends TestCase implements XSLTConstants
      >
      > {
      >
      > // have getters which return the of the (e.g.) XMLTestCase
      >
      > // Have setters which initializes (e.g.) XMLTestCase
      >
      > }
      >
      > OR:
      >
      > RulePointBaseTest extends XMLTestCase
      >
      > {
      > //just use dbunit tests ?? HOW
      >
      > }
      >
      > OR
      >
      > Have:
      >
      > RulePointBaseTest {}
      >
      > DBBaseTest{}
      >
      > XMLBaseTest{}
      >
      > and in RulePOintBaseTest{} instantiate DBUnitBaseTest, and
      > XMLUnitBaseTest, and use their methods
      >
      > Which one would be the best solution??
    • Kamal
      Bohm, Thanks for the excellent insight. First of all the application IS an API, for a web service and it has database, UI , and Business Logic. What i am
      Message 2 of 23 , Apr 1, 2008
      • 0 Attachment
        Bohm,
        Thanks for the excellent insight.

        First of all the application IS an API, for a web service and it has
        database, UI , and Business Logic.
        What i am trying to do is as follows:
        Use JUnit, DBUnit and XMLUnit to create Functional tests, and by
        functional tests i mean a "function" of the business unit.
        Let's say , create a user, and to use assert(from junit), Diff(from
        XMLUnit) and

        expectedTable and getTable(from DBUnit) .

        So use junit's assert to verify login
        use XMLUnit to verify the XML received from the service
        verify the data for username and password , using DBUnit

        Now the only issue is that i want this to be seamless.
        and by that i mean, to have one BaseTest class, which would provide ALL of these functions.
        (if it is possible) now, i have observed that:

        JUnit's test case, extends TestCase
        XMLUnit test Case extends XMLTestCase
        DBUnit test case extends DBTestCase

        How can i combine all three in one BaseTest?

        Options:

        1. Use Inner Class
        2. Have three Base Classes
        3. Use the static methods of these API's and just include the jar's
        4. Any other suggestion?

        I do understand your point of view, and you DO have a point, but, for
        Functional tests, i think the combined view might work.

        Thanks,
        -Kamal.



        Böhm wrote:
        >
        > Hi,
        >
        > I think it isn't a good solution to merge different APIs.
        > First, what's your intention?
        >
        > Maybe you should first try to identify your test domains, for example
        > DB-Tests, XML verfication tests and so on. Then you may create
        > different base tests for the different test domains. The main draw back
        > I see for a mega-testcase are the extensive dependencies to different
        > resources as also apis, you may need for the different test types.
        >
        > If you really have something like versatile services that serve allmost
        > anything, its helpfull to look for the services from different points
        > of view: db-service, xml-service and so on. Sometimes the interfaces
        > of the class under test give you a hint, what different points of
        > view the class serves and what different base tests you need to test
        > such a class thoroughly.
        >
        > Any further suggestions?
        >
        > > -----Original Message-----
        > > From: junit@yahoogroups.com <mailto:junit%40yahoogroups.com>
        > [mailto:junit@yahoogroups.com <mailto:junit%40yahoogroups.com>] On
        > > Behalf Of Kamal
        > > Sent: Montag, 31. März 2008 19:40
        > > To: junit@yahoogroups.com <mailto:junit%40yahoogroups.com>
        > > Subject: [junit] junit, dbunit and xmlunit
        > >
        > > How to have a framework that incorporates other API's seamlessly
        > >
        > > We are using JUnit for its versetile assertions - BaseTest = TestCase
        > >
        > > API - BaseTest Name - interface
        > >
        > > JUNIT - TestCase - implements public interface Test
        > >
        > > XMLUnit - XMLTestcase - public abstract class XMLTestCase
        > > extends junit.framework.TestCase implements XSLTConstants ,
        > > public interface XSLTConstants extends XMLConstants
        > >
        > > DBUnit - DBTestCase - implements public interface Test
        > >
        > > Create a RulePointBaseTest class
        > >
        > > RulePointBaseTest extends TestCase implements XSLTConstants
        > >
        > > {
        > >
        > > // have getters which return the of the (e.g.) XMLTestCase
        > >
        > > // Have setters which initializes (e.g.) XMLTestCase
        > >
        > > }
        > >
        > > OR:
        > >
        > > RulePointBaseTest extends XMLTestCase
        > >
        > > {
        > > //just use dbunit tests ?? HOW
        > >
        > > }
        > >
        > > OR
        > >
        > > Have:
        > >
        > > RulePointBaseTest {}
        > >
        > > DBBaseTest{}
        > >
        > > XMLBaseTest{}
        > >
        > > and in RulePOintBaseTest{} instantiate DBUnitBaseTest, and
        > > XMLUnitBaseTest, and use their methods
        > >
        > > Which one would be the best solution??
        >
        >



        [Non-text portions of this message have been removed]
      • Böhm, Martin
        Hi, is it really necessary to test through all application layers? Your functional test sounds like a test of a simple business function no matter of the back
        Message 3 of 23 , Apr 2, 2008
        • 0 Attachment
          Hi,

          is it really necessary to test through all application layers?
          Your functional test sounds like a test of a simple business
          function no matter of the back end in detail (DB, XML, Network
          Communication etc.).

          For example: If you create a user at your business layer, than
          I think it doesn't matter where and how the user is created (on
          LDAP or DB), because the business layer relies on some other
          db- or ldap functions, network communication and so on, that
          are separatly to test.

          In fact it is the business layer who simply manages a user,
          but relies on storing and retrieving in deeper layers. So I
          assume that the function you want to test aren't the storage
          routines and xml-communication but rather the user management
          functions: create user, find user and change user. Is it, what
          you want to trust in?

          In simple words: what to test?
          - Test that the business function of user creation works well?
          or
          - Test through all layers that the user creation first induces
          a correct xml, that induces a communication to a webservice,
          induces a xml-parse, induces a create method, induces a
          valid sql query, induces a slq injection proofed insert.

          In your case whats more convenient? To test through all layers
          or rely on tested deeper layers?

          > -----Original Message-----
          > From: junit@yahoogroups.com [mailto:junit@yahoogroups.com] On
          > Behalf Of Kamal
          > Sent: Dienstag, 1. April 2008 16:42
          > To: junit@yahoogroups.com
          > Subject: Re: [junit] junit, dbunit and xmlunit
          >
          > Bohm,
          > Thanks for the excellent insight.
          >
          > First of all the application IS an API, for a web service and
          > it has database, UI , and Business Logic.
          > What i am trying to do is as follows:
          > Use JUnit, DBUnit and XMLUnit to create Functional tests, and
          > by functional tests i mean a "function" of the business unit.
          > Let's say , create a user, and to use assert(from junit), Diff(from
          > XMLUnit) and
          >
          > expectedTable and getTable(from DBUnit) .
          >
          > So use junit's assert to verify login
          > use XMLUnit to verify the XML received from the service
          > verify the data for username and password , using DBUnit
          >
          > Now the only issue is that i want this to be seamless.
          > and by that i mean, to have one BaseTest class, which would
          > provide ALL of these functions.
          > (if it is possible) now, i have observed that:
          >
          > JUnit's test case, extends TestCase
          > XMLUnit test Case extends XMLTestCase
          > DBUnit test case extends DBTestCase
          >
          > How can i combine all three in one BaseTest?
          >
          > Options:
          >
          > 1. Use Inner Class
          > 2. Have three Base Classes
          > 3. Use the static methods of these API's and just include the
          > jar's 4. Any other suggestion?
          >
          > I do understand your point of view, and you DO have a point,
          > but, for Functional tests, i think the combined view might work.
          >
          > Thanks,
          > -Kamal.
          >
          > Böhm wrote:
          > >
          > > Hi,
          > >
          > > I think it isn't a good solution to merge different APIs.
          > > First, what's your intention?
          > >
          > > Maybe you should first try to identify your test domains,
          > for example
          > > DB-Tests, XML verfication tests and so on. Then you may create
          > > different base tests for the different test domains. The main draw
          > > back I see for a mega-testcase are the extensive dependencies to
          > > different resources as also apis, you may need for the
          > different test types.
          > >
          > > If you really have something like versatile services that serve
          > > allmost anything, its helpfull to look for the services
          > from different
          > > points of view: db-service, xml-service and so on. Sometimes the
          > > interfaces of the class under test give you a hint, what different
          > > points of view the class serves and what different base
          > tests you need
          > > to test such a class thoroughly.
          > >
          > > Any further suggestions?
          > >
          > > > -----Original Message-----
          > > > From: junit@yahoogroups.com <mailto:junit%40yahoogroups.com>
          > > > <mailto:junit%40yahoogroups.com>
          > > [mailto:junit@yahoogroups.com <mailto:junit%40yahoogroups.com>
          > > <mailto:junit%40yahoogroups.com>] On
          > > > Behalf Of Kamal
          > > > Sent: Montag, 31. März 2008 19:40
          > > > To: junit@yahoogroups.com <mailto:junit%40yahoogroups.com>
          > > > <mailto:junit%40yahoogroups.com>
          > > > Subject: [junit] junit, dbunit and xmlunit
          > > >
          > > > How to have a framework that incorporates other API's seamlessly
          > > >
          > > > We are using JUnit for its versetile assertions - BaseTest =
          > > > TestCase
          > > >
          > > > API - BaseTest Name - interface
          > > >
          > > > JUNIT - TestCase - implements public interface Test
          > > >
          > > > XMLUnit - XMLTestcase - public abstract class XMLTestCase extends
          > > > junit.framework.TestCase implements XSLTConstants ,
          > public interface
          > > > XSLTConstants extends XMLConstants
          > > >
          > > > DBUnit - DBTestCase - implements public interface Test
          > > >
          > > > Create a RulePointBaseTest class
          > > >
          > > > RulePointBaseTest extends TestCase implements XSLTConstants
          > > >
          > > > {
          > > >
          > > > // have getters which return the of the (e.g.) XMLTestCase
          > > >
          > > > // Have setters which initializes (e.g.) XMLTestCase
          > > >
          > > > }
          > > >
          > > > OR:
          > > >
          > > > RulePointBaseTest extends XMLTestCase
          > > >
          > > > {
          > > > //just use dbunit tests ?? HOW
          > > >
          > > > }
          > > >
          > > > OR
          > > >
          > > > Have:
          > > >
          > > > RulePointBaseTest {}
          > > >
          > > > DBBaseTest{}
          > > >
          > > > XMLBaseTest{}
          > > >
          > > > and in RulePOintBaseTest{} instantiate DBUnitBaseTest, and
          > > > XMLUnitBaseTest, and use their methods
          > > >
          > > > Which one would be the best solution??
        • Kamal
          Bohm, The reason for integrating all unit test frameworks, is that i am not taking the applications class as a unit to test. rather taking a functional test
          Message 4 of 23 , Apr 16, 2008
          • 0 Attachment
            Bohm,

            The reason for integrating all unit test frameworks, is that i am not
            taking the applications "class" as a unit to test.
            rather taking a functional test approach, like GET user ACL's , for that
            i would have to:
            1. Login to the application, using the SDK/API
            2. Issue a GET on a URI, to get user credentials

            i merely use JUnit/XMLUnit and DBUnit as utilities, in a single test
            - use JUnit assert to verify the HTTP response code
            - Use XMLUnit to verify the XML Doc i get back as a result of a POST Method
            - Use DBUnit to correlate the data from XML and Database

            I have no doubt that unit testing, is useful, but when it comes to
            application functionality, and scenario based testing, just JUnit does
            not provide the framework to accomplish such task.

            Now in order to unify the three frameworks, i use "Delegation" Pattern:

            public class RulePointBaseTest extends TestCase {

            /**
            * the logger for this class
            */
            protected static final Logger sLog =
            LogManager.getLogger(BaseTest.class);

            private XMLTestCase xmlTestCase;

            private DbUnitTask dbunitTask;

            public RulePointBaseTest() {
            this.xmlTestCase = new RulePointXmlTestCase();
            this.dbunitTask = new DbUnitTask();
            }

            /**
            * Inner class for RulePointXmlTestCase was created because there are no
            * abstract methods in XMLTestCase class
            *
            * @author kamal.ahmed
            *
            */
            private static class RulePointXmlTestCase extends XMLTestCase {

            }

            and then, i implement the getters and setters of the frameworks.


            Thanks,
            -Kamal.
          Your message has been successfully submitted and would be delivered to recipients shortly.