Pengenalan Unit Testing dan TDD
-
Upload
tlabamazing -
Category
Technology
-
view
157 -
download
10
description
Transcript of Pengenalan Unit Testing dan TDD
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, baca Laravel ==> sudah support PHP Unit, baca documentation Unit Testing Laraveldocumentation Unit Testing Laravel
Membuat Test CaseScript testing ada di app/testsTest 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); }}
Next...
public function pembagian($a,$b){
return $a/$b;
}
public function testPembagianPositif(){
$a=8; $b=2;respon = $this>call('GET', '/pembagian/'.$a.'/'.$b);
$this>assertEquals(4,$respon>original);}
#Fungsi yang akan di Tes:
#Fungsi untuk ngeTes:
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~