Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] TDD and Unit Testing in Magento 2 #171

Open
siju-corra opened this issue Aug 3, 2018 · 2 comments
Open

[Testing] TDD and Unit Testing in Magento 2 #171

siju-corra opened this issue Aug 3, 2018 · 2 comments

Comments

@siju-corra
Copy link

It would be great if you can dedicate few chapters for writing basic PHPUnit testing in Magento 2 and especially the TDD in Magento 2 way.

@Vinai
Copy link
Contributor

Vinai commented Aug 3, 2018

Thank you very much for the topic suggestion!

I really enjoy TDD in Magento 2. In fact, in 2016 I recorded a bunch of videos and put them on YouTube at https://www.youtube.com/mage2katas

Since then Magento has updated the PHPUnit version, so the syntax for using PHPUnit has changed a little, but the approaches and how to use the integration testing framework is still totally valid.

The main changes in regards to PHPUnit are that tests now extend from \PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase.
Also, instead of $this->getMock($class, [], [], '', false) to create a test double instance with a null constructor, the new method $this->createMock($class) must be used.
If any arguments are required for the test double, $this->getMockBuilder()->... has to be used as before.
And finally, the PHP methods to expect expectations changed. Exception expectations with annotations still work the same.

So, since there are only superficial changes, I think the topic already is fairly well covered. There are quite a few other topics I want to cover first before covering TDD and testing in Mage2 TV.

If this topic gets a lot of thumbs up here I will be happy to prioritize it.

@siju-corra
Copy link
Author

Thanks Vinai for the quick response. I have already been following your Mage2katas channel and found they are mostly integration testing.
All the topics you are posting in the mage2.tv are useful. I will look forward to get more thumbs up for this topic too 👍
Thanks

@Vinai Vinai changed the title TDD in Magento 2 [Testing] TDD in Magento 2 Aug 4, 2018
@Vinai Vinai changed the title [Testing] TDD in Magento 2 [Testing] TDD and Unit Testing in Magento 2 Aug 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants