Uploaded by Moshiur Sumon

Unit Testing

advertisement
Unit Testing- PHPUnit
Every developer understands how inconvenient bugs can be, especially during the
production stage when hours of effort are required. Despite the development team's
best efforts to eliminate problems during the development process, bugs continue to
leak into the code. So, what can be done to remedy these flaws while also removing
the tedious work of manual testing? One option is to use Unit Testing, Unit testing
is used to test individual units of an application during the coding stage of a software
development project. Its purpose is to ensure that each unit of software code operates
as expected. In object-oriented languages, a unit is a class or class method, while in
procedural and functional software languages, it is a process or function. Unit tests
must run rapidly, thus they are performed in isolation from other processes or
systems. PHPUnit is a framework independent library for unit testing PHP. Unit
testing is a method by which small units of code are tested against expected results.
Installing PHPUnit on Ubuntu
1. First, open the Windows cmd and change it to the Ubuntu cmd by typing "bash".
To begin, check to see if your device already has Ubuntu installed on Windows; if
not, go to this link.
https://www.youtube.com/watch?v=X-DHaQLrBi8
2. After you've installed PHP on Ubuntu cmd by switching from Windows cmd to
Ubuntu cmd, you can now install the PHPUnit tool with just two commands on
Ubuntu cmd.
"$ sudo apt-get update -y"
"$ sudo apt-get install -y phpunit"
For more https://zoomadmin.com/HowToInstall/UbuntuPackage/phpunit
3. Run the command "$ phpunit —version" to get the phpunit version from the
installation confirmation.
4. Go to the test file directory and run the test file with the following command: "$
phpunit —verbose test.php," where test is the file name. The function testing result
will then tell you whether the function is working properly or not.
Download