5

I have created a module in magento 2. And need to create the Unit tests for it. I can see that Each core module has its own Test folder containing tests for each component like Controller, Block,Model,etc.

But they are hard to understand, and magento has not provided the tuttorial for the same. can anyone suggest any source where i can learn the unittesting framework from basics?

I got idea how to test it but I don't know how to create it. http://devdocs.magento.com/guides/v2.0/mtf/mtf_update.html

Please help to do this stuff.

  • We're working on tutorials. As for the documentation, it currently is more about integration tests, which will be the last thing that you create. – benmarks Oct 28 '15 at 9:29
  • Okay so I will wait for it. thank you @benmarks – Praful Rajput Oct 28 '15 at 10:13
  • I also found the best solution for run the test magento.stackexchange.com/questions/86579/… – Praful Rajput Oct 28 '15 at 13:20
  • Correction. The MTF is functional tests. We're investigating documenting other types of testing. – Steve Johnson Oct 28 '15 at 14:06
5

The best I can suggest for now is reading up on PHP Unit and looking at other test scripts provided with the code base. I do not recall more unit testing examples being high on the doc teams list at the moment.

Some other reading that might be useful.

  • Thanks Alan, Now we get idea how to write test class for custom module. Still I am getting problem while How to test a created test class methods. Other than M2 we are able to do it. But in m2 How we can test it using CLI ? We also perform the automation of test in m2 its working fine. Que is only limited for our custom module. – Praful Rajput Dec 10 '15 at 5:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.