2. UNIT TESTING
Unit Testing adalah suatu metode untuk
melakukan pengetesan pada unit terkecil program
(function) secara otomatis dengan menggunakan
kode-kode program.
Membuat program untuk mengetes program.
Tools PHP:
➢ PHP Unit
➢
Laravel ==> sudah support PHP Unit, bacaLaravel ==> sudah support PHP Unit, baca
documentation Unit Testing Laraveldocumentation Unit Testing Laravel
3. Membuat Test Case
Script testing ada di app/tests
Test Class harus meng-extend TestCase.
Contoh:
Cara memanggil Testnya:
Masuk terminalmasuk folder project – ketik
phpunit
class FooTest extends TestCase {
public function testSomethingIsTrue()
{
$this>assertTrue(true);
}
}
6. TDD -TEST DRIVEN DEVELOPMENT-
Testing First, Then Code
Test-driven development (TDD) is a software development
process that relies on the repetition of a very short development
cycle: first the developer writes an (initially failing) automated
test case that defines a desired improvement or new function,
then produces the minimum amount of code to pass that test, and
finally refactors the new code to acceptable standards.
~wikipedia~