Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-11247

Providing utilities for integration tests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • ALL APPLICATIONS, framework
    • None

    Description

      At https://markmail.org/message/bdf4ntvwwdl4hxtx mthl suggested:

      In order to avoid repetitive code a nice first helper method would be
      for example one for retrieving the default userLogin like what is done
      in 'QuoteTests.groovy'

          // Retrieves a particular login record.
          GenericValue getUserLogin(String userLoginId) {
              GenericValue userLogin = EntityQuery.use(delegator)
                      .from('UserLogin').where(userLoginId: userLoginId).queryOne()
              assert userLogin
              return userLogin
          }
      

      We could even add a default login user.

          // Retrieves the default login record.
          GenericValue getUserLogin() {
              return getUserLogin('system');
          }
      

      I guess we should add such method directly in the 'OFBizTestCase' class
      to be able to reuse it in all test cases and avoid having to pass the
      'delegator' and 'dispatcher' as method arguments.

      The creation of the service input map of your example would look like
      this:

           void testSendOrderChangeNotification() {
               Map serviceCtx = [
                   orderId: 'TEST_DEMO10090',
                   sendTo: 'test_email@example.com',
                   userLogin: getUserLogin()
               ]
               Map serviceResult = dispatcher.runSync('sendOrderChangeNotification', serviceCtx)
               assert ServiceUtil.isSuccess(serviceResult)
               assert serviceResult.emailType.equals("PRDS_ODR_CHANGE")
           }
      

      In any case I think that finding the generic and reusable helper methods
      can be done incrementally.

      Attachments

        1. OFBIZ-11247.patch
          2 kB
          Pawan Verma
        2. OFBIZ-11247.patch
          0.8 kB
          Pawan Verma

        Activity

          People

            Unassigned Unassigned
            jleroux Jacques Le Roux
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: