简体   繁体   中英

How to execute phpunit in browsers?

I am working in web application project using php, mysql and zend framework extension classes. And my task is to write unit test case for web application. I read following document https://phpunit.de/manual/4.3/en/installation.html and saw some sample also. Even though i cant to understand fully. I dont know how to practice sample code in browser. So anyone guide me how to start phpunit framework testcase. And one more important what are the classes I have to write unit test case.

You are at the beginning of a painful testing journey. In the nutshell there are two basic types: unit and functional testing, there are many answers on what is the difference between the two, like this one .

Typically everything start with unit testing, when you create a basic command / function and use a unit test to confirm that they work as expected as an independent unit. Once you finish combining those commands into a fully functional part of your application (controller action / piece of code that handles the request and returns a response) you use a functional test to confirm that they provide the required business logic. Normally only the functional testing involves using the browser or browser simulator (in the PHP / server side development context).

With that in mind, you can test majority of your code with unit tests using PHPUnit, it also would be easier to begin with. For functional testing there is an amazing Behat and Mink projects. You should do your own research on the whole subject, but be prepared that this is not a few hours job, especially if you are new to this. Those links will help you kickstart your learning:

8 Must Have PHP Quality Assurance Tools
Getting Started with PHPUnit
BDD With Behat
Practical BDD with Behat and Mink
Google the search engine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM