OFBiz
  1. OFBiz
  2. OFBIZ-1463

JUnit test case for various application components

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: Trunk
    • Fix Version/s: None
    • Component/s: framework
    • Labels:
      None
    • Sprint:
      Bug Crush Event - 21/2/2015

      Description

      This is an effort to create JUnit test suites for various bussiness processes in Ofbiz.
      It would be good to have such tests in place so that we can test Ofbiz on a certain day.

      These tests are in initial stage, so I would like community members to post there comments so that we can move
      ahead with them to make these test even better.

        Issue Links

        1. JUnit Test case for update and return order. Sub-task Open Unassigned
         
        2. Credits, Refunds... Sub-task Open Unassigned
         
        3. Fulfillment with Picker & Packer Roles : Order Picking Sub-task Open Unassigned
         
        4. Warehouse Manager Role : Receive Purchase Order Sub-task Open Unassigned
         
        5. Unit test case for service - createDataCategory Sub-task Open Unassigned
         
        6. Unit test case for service - updateDataCategory Sub-task Open Unassigned
         
        7. Unit test case for service - removeDataCategory Sub-task Open Unassigned
         
        8. Unit test case for service - getDataResource Sub-task Patch Available Unassigned
         
        9. Unit test case for service - createDataResourceRole Sub-task Open Unassigned
         
        10. Unit test case for service - updateDataResourceRole Sub-task Open Unassigned
         
        11. Unit test case for service - removeDataResourceRole Sub-task Open Unassigned
         
        12. Unit test case for service - createEmailContent Sub-task Open Unassigned
         
        13. Unit test case for service - updateEmailContent Sub-task Open Unassigned
         
        14. Unit test case for service - createSimpleTextContent Sub-task Open Unassigned
         
        15. Unit test case for service - createPartyPostalAddress Sub-task Open Unassigned
         
        16. Unit test case for service - updateSimpleTextContent Sub-task Open Unassigned
         
        17. Unit test case for service - createTopic Sub-task Open Unassigned
         
        18. Unit test case for service - checkContentAssocIds Sub-task Open Unassigned
         
        19. Unit test case for service - getContent Sub-task Open Unassigned
         
        20. Unit test case for service - updateProductCategory Sub-task Patch Available Unassigned
         
        21. Unit test case for service - deleteProductCategory Sub-task Open Unassigned
         
        22. Unit test case for service - createPostalAddressAndPurposes Sub-task Open Unassigned
         
        23. JUnit test case for Creating a Retrun Header Sub-task Patch Available Unassigned
         
        24. Unit test case for service - quickReturnOrder Sub-task Patch Available Unassigned
         
        25. Unit test case for service - SendOrderBackorderNotification Sub-task Patch Available Unassigned
         
        26. Unit test case for service - sendOrderChangeNotification Sub-task Patch Available Unassigned
         
        27. Unit test case for service - sendOrderCompleteNotification Sub-task Patch Available Unassigned
         
        28. Unit test case for service - sendOrderPayRetryNotification Sub-task Patch Available Unassigned
         
        29. Unit test case for service - CheckPaymentAmountForRefund Sub-task Patch Available Unassigned
         
        30. Unit test case for service - CheckReturnComplete Sub-task Patch Available Unassigned
         
        31. Unit test case for service - CreateReturnAdjustment Sub-task Patch Available Unassigned
         
        32. Unit test case for service - CreateReturnAndItemOrAdjustment Sub-task Patch Available Unassigned
         
        33. Unit test case for service - CreateReturnItemShipment Sub-task Patch Available Unassigned
         
        34. Unit test case for service - CreateReturnStatus Sub-task Patch Available Unassigned
         
        35. Unit test case for service - GetReturnAmountByOrder Sub-task Patch Available Unassigned
         
        36. Unit test case for service - GetReturnItemInitialCost Sub-task Patch Available Unassigned
         
        37. Unit test case for service - ProcessCreditReturn Sub-task Patch Available Unassigned
         
        38. Unit test case for service - ProcessCrossShipReplacementReturn Sub-task Patch Available Unassigned
         
        39. Unit test case for service - ProcessRefundImmediatelyReturn Sub-task Patch Available Unassigned
         
        40. Unit test case for service - ProcessRefundOnlyReturn Sub-task Patch Available Unassigned
         
        41. Unit test case for service - ProcessRefundReturn Sub-task Patch Available Unassigned
         
        42. Unit test case for service - ProcessRefundReturnForReplacement Sub-task Patch Available Unassigned
         
        43. Unit test case for service - ProcessRepairReplacementReturn Sub-task Patch Available Unassigned
         
        44. Unit test case for service - ProcessReplaceImmediatelyReturn Sub-task Patch Available Unassigned
         
        45. Unit test case for service - ProcessReplacementReturn Sub-task Patch Available Unassigned
         
        46. Unit test case for service - ProcessSubscriptionReturn Sub-task Patch Available Unassigned
         
        47. Unit test case for service - ProcessWaitReplacementReservedReturn Sub-task Patch Available Unassigned
         
        48. Unit test case for service - ProcessWaitReplacementReturn Sub-task Patch Available Unassigned
         
        49. Unit test case for service - AddRequirementTask Sub-task Patch Available Unassigned
         
        50. Unit test case for service - createInvoiceContent Sub-task Patch Available Unassigned
         
        51. Unit test case for service - AssociatedRequirementWithRequestItem Sub-task Patch Available Unassigned
         
        52. Unit test case for service - AutoAssignRequirementToSupplier Sub-task Patch Available Unassigned
         
        53. Unit test case for service - CheckCreateOrderRequirement Sub-task Patch Available Unassigned
         
        54. Unit test case for service - createSimpleTextContentForInvoice Sub-task Patch Available Unassigned
         
        55. Unit test case for service - CheckCreateProductRequirementForFacility Sub-task Patch Available Unassigned
         
        56. Unit test case for service - CheckCreateStockRequirementAtp Sub-task Patch Available Unassigned
         
        57. Unit test case for service - CheckCreateStockRequirementQoh Sub-task Patch Available Unassigned
         
        58. Unit test case for service - CustRequestPermissionCheck Sub-task Patch Available Unassigned
         
        59. Unit test case for service - createAcctgTrans Sub-task Patch Available Unassigned
         
        60. Unit test case for service - createAcctgTransEntry Sub-task Patch Available Unassigned
         
        61. Unit test case for service - createPayment Sub-task Patch Available Unassigned
         
        62. Unit test case for service - setPaymentStatus Sub-task Patch Available Unassigned
         
        63. Unit test case for service - quickSendPayment Sub-task Patch Available Unassigned
         
        64. Unit test case for service - addProductCategoryToCategory Sub-task Patch Available Unassigned
         
        65. Unit test case for service - createProductFeatureType Sub-task Patch Available Unassigned
         
        66. Unit test case for service - createProductConfigOption Sub-task Patch Available Unassigned
         
        67. Unit test case for service - getPayments Sub-task Patch Available Unassigned
         
        68. Unit test case for service - createPaymentContent Sub-task Patch Available Unassigned
         
        69. Unit test case for service - updatePaymentGatewayConfig Sub-task Patch Available Unassigned
         

          Activity

          Hide
          Vikas Mayur added a comment -

          Marco, you are most welcome to review and commit these patches.

          Show
          Vikas Mayur added a comment - Marco, you are most welcome to review and commit these patches.
          Hide
          Taher Alkhateeb added a comment -

          Hello everyone,

          It is important to note in here that the old OFBiz tests are really integration tests, not unit tests. Therefore, please note the following comments / recommendations:

          • If your test does not need a database or some environment context, then convert it to a unit test
          • Real unit tests are very fast, if it takes time (because of using external resources) then keep it as an integration test
          • Unit tests are automatically run everytime you call ./gradlew build or run any server commands.
          • Unit tests can be explicitly called by the command ./gradlew test
          • Recommend to keep the JUnit tests as pure junit (nothing OFBiz related)
          • Recommend using the annotations instead of starting each test name with test...
          • Highly recommend using ExpectedException and _assertThat(actual, expected) API over other older classical test methods.
          • You might need to create mock objects for your tests. This is where mockito might be helpful. I will propose something on the ML once I hit a test requirement to introduce it.

          I will create a Sub-JIRA to commit some tests for the Start component which you can use as a reference If you like to.

          Show
          Taher Alkhateeb added a comment - Hello everyone, It is important to note in here that the old OFBiz tests are really integration tests, not unit tests. Therefore, please note the following comments / recommendations: If your test does not need a database or some environment context, then convert it to a unit test Real unit tests are very fast, if it takes time (because of using external resources) then keep it as an integration test Unit tests are automatically run everytime you call ./gradlew build or run any server commands. Unit tests can be explicitly called by the command ./gradlew test Recommend to keep the JUnit tests as pure junit (nothing OFBiz related) Recommend using the annotations instead of starting each test name with test... Highly recommend using ExpectedException and _assertThat(actual, expected) API over other older classical test methods. You might need to create mock objects for your tests. This is where mockito might be helpful. I will propose something on the ML once I hit a test requirement to introduce it. I will create a Sub-JIRA to commit some tests for the Start component which you can use as a reference If you like to.
          Hide
          Jacques Le Roux added a comment -

          I know it's totally out of subject and certainly premature but should we not do that with http://junit.org/junit5/ in mind? Or even maybe play daredevils and use it already (after all it's trunk)?

          Show
          Jacques Le Roux added a comment - I know it's totally out of subject and certainly premature but should we not do that with http://junit.org/junit5/ in mind? Or even maybe play daredevils and use it already (after all it's trunk)?
          Hide
          Taher Alkhateeb added a comment -

          Hmmmmm, It is certainly doable with gradle. I think the technology is still beta and we are expected to make a release branch soon. Perhaps we can upgrade junit after the branch? As far as I know the syntax is very much the same and only new features are added such as the ability to use lambda expressions in assertions. So I think an upgrade is not difficult.

          Show
          Taher Alkhateeb added a comment - Hmmmmm, It is certainly doable with gradle. I think the technology is still beta and we are expected to make a release branch soon. Perhaps we can upgrade junit after the branch? As far as I know the syntax is very much the same and only new features are added such as the ability to use lambda expressions in assertions. So I think an upgrade is not difficult.
          Hide
          Pierre Smits added a comment - - edited

          We all know trunk can be a volatile branch and things can get broken from time to time, but that doesn't mean that is should be used as a testbed for some piece of 3rd party software the community has no experience with.

          That being said, why don't you do a Proof of Concept first in your own dev environment and share results with the community? So that it can look for follow-up actions.

          Show
          Pierre Smits added a comment - - edited We all know trunk can be a volatile branch and things can get broken from time to time, but that doesn't mean that is should be used as a testbed for some piece of 3rd party software the community has no experience with. That being said, why don't you do a Proof of Concept first in your own dev environment and share results with the community? So that it can look for follow-up actions.
          Hide
          Taher Alkhateeb added a comment - - edited

          Hello everyone, I've introduced unit tests to the start component in OFBIZ-7897 which helped me actually detect some minor errors in the code. If you wish you can use these tests as a reference of how to introduce unit tests utilizing gradle. These tests automatically run every time you call build, test, or run any of the server commands (upon any code change). If no change in the code is detected then the tests are cached and not run again (just like ant or any other build system)

          Show
          Taher Alkhateeb added a comment - - edited Hello everyone, I've introduced unit tests to the start component in OFBIZ-7897 which helped me actually detect some minor errors in the code. If you wish you can use these tests as a reference of how to introduce unit tests utilizing gradle. These tests automatically run every time you call build, test, or run any of the server commands (upon any code change). If no change in the code is detected then the tests are cached and not run again (just like ant or any other build system)

            People

            • Assignee:
              Unassigned
              Reporter:
              Vikas Mayur
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development

                  Agile