3

I am working on magento 2 project. I am using Jenkins as continuous integration tool. How can I use Jenkins for PHP unit testing for Magento 2. I know Magento 2 has inbuilt tool for unit testing. How can I use this inbuilt testing tool with jerkins.

| improve this question | | | | |
  • this depends on if you just want to execute unit tests (with no dependencies on the magento framework) or want to utilize the magento testing frameworks. Setting up a ci env for just running unit tests without utilizing the magento framework is quite easy while utilizing the magento testing frameworks adds a lot of complexity, depending on the type of tests you want to execute – David Verholen Dec 22 '16 at 19:52
  • @DavidVerholen I want to use magento unit testing framework. – Pandurang Dec 23 '16 at 9:25
2

to use the magento testing frameworks you need the magento codebase in your build. So if not in your repository, the first step would be to deploy magento

in the dev/tests/unit directory you find a phpunit.xml.dist which is preconfigured to execute the Magento tests.

you need a copy of this file in your repository, but without the .dist at the end and adjust it so that phpunit will execute your own tests.

so the next step would be to ensure you have the adjusted file at dev/tests/unit/phpunit.xml

next, you can execute phpunit from the test directory like this (example shell script):

cd dev/tests/unit && ../../../vendor/bin/phpunit -c phpunit.xml
| improve this answer | | | | |
  • Do you need to have run magento setup:install or is composer install enough? – Stevie G Feb 6 '17 at 9:45

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.