I created a module that has some logic to modify the price of certain items depending on a few conditions pertaining to the other items in the cart.

I'm trying to write a unit test to test that the price of the items will be modified as expected.

I'm struggling to figure out how do I pass different cart contents to my test, since my class only gets instantiated as an observer on the add_to_cart event.

I might be missing something obvious, but I've looked around and cannot seem to see how this should be done.

  • I'm also trying to figure this out.... – Yehuda Schwartz Oct 16 '18 at 18:01
  • I figured it out already – Haim Oct 16 '18 at 18:01
  • Can you please share your solution? – sv3n Dec 7 '18 at 15:56
  • @sv3n it boils down to understanding the differences between unit testing, integration testing and functional testing. In unit testing using mocks will do the trick. – Haim Dec 7 '18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.