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

Providing utilities for integration tests

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ALL APPLICATIONS, framework
    • Labels:
      None

      Description

      At https://markmail.org/message/bdf4ntvwwdl4hxtx Mathieu Lirzin 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

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jleroux Jacques Le Roux
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: