SlideShare a Scribd company logo
1 of 21
Download to read offline
Manajemen dan Kualitas Perangkat Lunak
              IKP321

             Unit Testing
Unit

   Perangkat Lunak
        Code
        Documentation
        Procedure
        Data
   Satuan terkecil Code
        Unit
        Method atau Function atau Procedure
Unit Testing

   Test-case untuk Unit
   Spesifikasi
        Pemanggilan Unit
        Ekspektasi luaran yang dihasilkan oleh Unit
   Menguji apakah Unit sudah berfungsi sebagaimana yang
    diharapkan (as expected)
   Menguji Unit secara independen, tanpa bergantung pada
    hasil komputasi Unit lain
Rehat Sejenak: Python

   Bahasa pemrograman Scripting
   Interpreter
   Multi platform
   Pengguna
        Google
        NASA
        etc.
        This class
   'Secret Weapon'
Python

   Dapat diunduh dari
        http://www.python.org/getit
   Sesuaikan dengan platform komputer masing-masing
    (Windows, Linux, Mac OS)
   Per April 2012, ada dua versi Python
        2.7.2
        3.2.2
   Gunakan versi 2.7.2
IDLE

   Editor sederhana untuk Python
   Bagian dari paket instalasi standar
   Start → Python 2.7.2 → IDLE (Python GUI)
        Mulai menjalankan Python Shell
   File → New Window
        Membuka jendela IDLE
   File → Save As
        "hello.py"
        Letakkan di folder yang mudah diingat dan diakses
         (C:Usersuser)
IDLE

   Ketik di jendela IDLE
        print ("Ini program Python pertamaku.")
   Jalankan program
        Alt + R → Run Module
        Tekan tombol F5
IDLE
IDLE
Fungsi dan Docstring

   Dokumentasi internal dalam program Python
   Jendela IDLE
        File → New Window
        File → Save As
                "maxthree.py"
   Definisikan sebuah fungsi
Fungsi dan Docstring
Fungsi dan Docstring

   Docstring mendokumentasikan deskripsi dan spesifikasi
    sebuah fungsi
   Bagian dari dokumentasi online (online help) dalam
    Python Shell
        Jendela Python Shell
        import maxthree
        help(maxthree)
Fungsi dan Docstring
Rehat Selesai: Doctest

   Bagian dari Docstring
   'Memanggil' fungsi Python sebagai bagian dari test-case
   Test case untuk maxthree
       >>> maxthree(3, 2, 1)
       3
       >>> maxthree(3, 2, 3)
       3
       >>> maxthree(-1,-2, -3)
       -1
Doctest
Menjalankan Doctest

             Jalankan dari Command
              Prompt
                 python -m doctest
                  maxthree.py
Mengimplementasikan Code Fungsi

   Doctest dapat dituliskan sebelum body dari fungsi ditulis
   Doctest memberikan test-case yang fail
   Sebelum code fungsi belum diimplementasikan, semua
    test-case pasti fail
   Doctest memberikan spesifikasi tentang apa yang di-
    expect dari sebuah fungsi
Mengimplementasikan Code Fungsi
Memeriksa Test-case

             Tidak ada test-case yang
              fail
                  python -m doctest
                   maxthree.py
             Gunakan option -v untuk
              menampilkan rincian Unit
              Test
                  python -m doctest -v
                   maxthree.py
Online Help

         Docstring terupdate
          dengan informasi Doctest
         Python Shell
              reload(maxthree)
              help(maxthree)
Pustaka

   www.python.org/getit/
   http://www.annedawson.net/Python_Editor_IDLE.htm
   starship.python.net/~tbryan/UnitTestTalk/index.html
   tjerdastangkas.blogspot.com/search/label/ikp321

More Related Content

Viewers also liked

Batismo:compromisso e obediência
Batismo:compromisso e obediênciaBatismo:compromisso e obediência
Batismo:compromisso e obediência
Paulo Dias Nogueira
 
O Batismo nas Águas
O Batismo nas ÁguasO Batismo nas Águas
O Batismo nas Águas
Karla Nielle
 
Fall Fitness Challenge
Fall Fitness ChallengeFall Fitness Challenge
Fall Fitness Challenge
Greg Cox
 
Redshift Company Credentials
Redshift Company CredentialsRedshift Company Credentials
Redshift Company Credentials
Lisa_Bella
 

Viewers also liked (20)

Os elementos da natureza nos ritos religiosos
Os elementos da natureza nos ritos religiososOs elementos da natureza nos ritos religiosos
Os elementos da natureza nos ritos religiosos
 
Sacramento do Batismo
Sacramento do BatismoSacramento do Batismo
Sacramento do Batismo
 
Batismo:compromisso e obediência
Batismo:compromisso e obediênciaBatismo:compromisso e obediência
Batismo:compromisso e obediência
 
O batismo em nome de jesus
O batismo em nome de jesusO batismo em nome de jesus
O batismo em nome de jesus
 
Projeto Água
Projeto ÁguaProjeto Água
Projeto Água
 
Batismo em aguas
Batismo em aguasBatismo em aguas
Batismo em aguas
 
O Batismo nas Águas
O Batismo nas ÁguasO Batismo nas Águas
O Batismo nas Águas
 
Arte e água
Arte e águaArte e água
Arte e água
 
Aula 01 o batismo nas águas
Aula 01   o batismo nas águasAula 01   o batismo nas águas
Aula 01 o batismo nas águas
 
Religiões
ReligiõesReligiões
Religiões
 
O batismo nas águas
O batismo nas águasO batismo nas águas
O batismo nas águas
 
Vortex Tutorial Part II
Vortex Tutorial Part IIVortex Tutorial Part II
Vortex Tutorial Part II
 
Distributed Events, State and Commands
Distributed Events, State and CommandsDistributed Events, State and Commands
Distributed Events, State and Commands
 
Fall Fitness Challenge
Fall Fitness ChallengeFall Fitness Challenge
Fall Fitness Challenge
 
Valentine's day
Valentine's dayValentine's day
Valentine's day
 
2015 Back To School Transformation Challenge
2015 Back To School Transformation Challenge2015 Back To School Transformation Challenge
2015 Back To School Transformation Challenge
 
Living in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working GroupLiving in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working Group
 
архитектура компьютера
архитектура компьютераархитектура компьютера
архитектура компьютера
 
Option a kranjska gora
Option a kranjska goraOption a kranjska gora
Option a kranjska gora
 
Redshift Company Credentials
Redshift Company CredentialsRedshift Company Credentials
Redshift Company Credentials
 

Similar to ikp321-03

Dasar pemrograman-python
Dasar pemrograman-pythonDasar pemrograman-python
Dasar pemrograman-python
namasaja
 
Endi sourcecodevb
Endi sourcecodevbEndi sourcecodevb
Endi sourcecodevb
Jamil Jamil
 
Codeigniter lanjut helper dan library
Codeigniter lanjut helper dan libraryCodeigniter lanjut helper dan library
Codeigniter lanjut helper dan library
boys of separato
 

Similar to ikp321-03 (20)

Prak 1
Prak 1Prak 1
Prak 1
 
Dasar pemrograman-python
Dasar pemrograman-pythonDasar pemrograman-python
Dasar pemrograman-python
 
Python Programming Basic
Python Programming BasicPython Programming Basic
Python Programming Basic
 
Lapres 4 dan 5 1235010002
Lapres 4 dan 5   1235010002Lapres 4 dan 5   1235010002
Lapres 4 dan 5 1235010002
 
Modul belajar java I/O (Input/Ouptut)
Modul belajar java I/O (Input/Ouptut)Modul belajar java I/O (Input/Ouptut)
Modul belajar java I/O (Input/Ouptut)
 
Endi sourcecodevb
Endi sourcecodevbEndi sourcecodevb
Endi sourcecodevb
 
57718.pptx
57718.pptx57718.pptx
57718.pptx
 
Membuat Catatan Online dengan Cherrypy
Membuat Catatan Online dengan CherrypyMembuat Catatan Online dengan Cherrypy
Membuat Catatan Online dengan Cherrypy
 
Membuat Aplikasi/Modul di Odoo ERP
Membuat Aplikasi/Modul di Odoo ERPMembuat Aplikasi/Modul di Odoo ERP
Membuat Aplikasi/Modul di Odoo ERP
 
Codeigniter lanjut helper dan library
Codeigniter lanjut helper dan libraryCodeigniter lanjut helper dan library
Codeigniter lanjut helper dan library
 
PythonTeX Quick Start
PythonTeX Quick StartPythonTeX Quick Start
PythonTeX Quick Start
 
Modul metasploit
Modul metasploitModul metasploit
Modul metasploit
 
Dokumen Kode Program.pdf
Dokumen Kode Program.pdfDokumen Kode Program.pdf
Dokumen Kode Program.pdf
 
Instalasi python 3 dan ide atau anaconda distribution pada windows 10
Instalasi python 3 dan ide atau anaconda distribution pada windows 10Instalasi python 3 dan ide atau anaconda distribution pada windows 10
Instalasi python 3 dan ide atau anaconda distribution pada windows 10
 
IPython
IPythonIPython
IPython
 
Python Awal
Python AwalPython Awal
Python Awal
 
Django Mini Tutorial
Django Mini TutorialDjango Mini Tutorial
Django Mini Tutorial
 
Laporan Modul 1 Praktikum Pemrograman Berbasis Objek
Laporan Modul 1 Praktikum Pemrograman Berbasis ObjekLaporan Modul 1 Praktikum Pemrograman Berbasis Objek
Laporan Modul 1 Praktikum Pemrograman Berbasis Objek
 
PBO Pratikum 1
PBO Pratikum 1PBO Pratikum 1
PBO Pratikum 1
 
Fundamental Django, dan Contoh Program CRUD Katalog Buku Perpustakaan.
Fundamental Django, dan Contoh Program CRUD Katalog Buku Perpustakaan.Fundamental Django, dan Contoh Program CRUD Katalog Buku Perpustakaan.
Fundamental Django, dan Contoh Program CRUD Katalog Buku Perpustakaan.
 

More from Anung Ariwibowo (20)

isd314-06-association-mining
isd314-06-association-miningisd314-06-association-mining
isd314-06-association-mining
 
ikp213-unifikasi
ikp213-unifikasiikp213-unifikasi
ikp213-unifikasi
 
ikp213-06-horn-clause
ikp213-06-horn-clauseikp213-06-horn-clause
ikp213-06-horn-clause
 
ikp213-01-pendahuluan
ikp213-01-pendahuluanikp213-01-pendahuluan
ikp213-01-pendahuluan
 
ikd312-05-sqlite
ikd312-05-sqliteikd312-05-sqlite
ikd312-05-sqlite
 
ikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasionalikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasional
 
ikd312-04-aljabar-relasional
ikd312-04-aljabar-relasionalikd312-04-aljabar-relasional
ikd312-04-aljabar-relasional
 
ikd312-03-design
ikd312-03-designikd312-03-design
ikd312-03-design
 
ikd312-02-three-schema
ikd312-02-three-schemaikd312-02-three-schema
ikd312-02-three-schema
 
ikp213-02-pendahuluan
ikp213-02-pendahuluanikp213-02-pendahuluan
ikp213-02-pendahuluan
 
ikh311-08
ikh311-08ikh311-08
ikh311-08
 
ikh311-07
ikh311-07ikh311-07
ikh311-07
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
ikp321-svn
ikp321-svnikp321-svn
ikp321-svn
 
ikh311-04
ikh311-04ikh311-04
ikh311-04
 
ikp321-05
ikp321-05ikp321-05
ikp321-05
 
imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09
 
ikh311-03
ikh311-03ikh311-03
ikh311-03
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
 

Recently uploaded

HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.pptHAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
nabilafarahdiba95
 

Recently uploaded (20)

OPTIMALISASI KOMUNITAS BELAJAR DI SEKOLAH.pptx
OPTIMALISASI KOMUNITAS BELAJAR DI SEKOLAH.pptxOPTIMALISASI KOMUNITAS BELAJAR DI SEKOLAH.pptx
OPTIMALISASI KOMUNITAS BELAJAR DI SEKOLAH.pptx
 
MODUL AJAR BAHASA INDONESIA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL AJAR BAHASA INDONESIA KELAS 6 KURIKULUM MERDEKA.pdfMODUL AJAR BAHASA INDONESIA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL AJAR BAHASA INDONESIA KELAS 6 KURIKULUM MERDEKA.pdf
 
Salinan dari JUrnal Refleksi Mingguan modul 1.3.pdf
Salinan dari JUrnal Refleksi Mingguan modul 1.3.pdfSalinan dari JUrnal Refleksi Mingguan modul 1.3.pdf
Salinan dari JUrnal Refleksi Mingguan modul 1.3.pdf
 
HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.pptHAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
HAK DAN KEWAJIBAN WARGA NEGARA ppkn i.ppt
 
SOAL PUBLIC SPEAKING UNTUK PEMULA PG & ESSAY
SOAL PUBLIC SPEAKING UNTUK PEMULA PG & ESSAYSOAL PUBLIC SPEAKING UNTUK PEMULA PG & ESSAY
SOAL PUBLIC SPEAKING UNTUK PEMULA PG & ESSAY
 
vIDEO kelayakan berita untuk mahasiswa.ppsx
vIDEO kelayakan berita untuk mahasiswa.ppsxvIDEO kelayakan berita untuk mahasiswa.ppsx
vIDEO kelayakan berita untuk mahasiswa.ppsx
 
DEMONSTRASI KONTEKSTUAL MODUL 1.3 CGP 10.pptx
DEMONSTRASI KONTEKSTUAL MODUL 1.3 CGP 10.pptxDEMONSTRASI KONTEKSTUAL MODUL 1.3 CGP 10.pptx
DEMONSTRASI KONTEKSTUAL MODUL 1.3 CGP 10.pptx
 
BAHAN PAPARAN UU DESA NOMOR 3 TAHUN 2024
BAHAN PAPARAN UU DESA NOMOR 3 TAHUN 2024BAHAN PAPARAN UU DESA NOMOR 3 TAHUN 2024
BAHAN PAPARAN UU DESA NOMOR 3 TAHUN 2024
 
Program Kerja Public Relations - Perencanaan
Program Kerja Public Relations - PerencanaanProgram Kerja Public Relations - Perencanaan
Program Kerja Public Relations - Perencanaan
 
MODUL AJAR MATEMATIKA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL AJAR MATEMATIKA KELAS 6 KURIKULUM MERDEKA.pdfMODUL AJAR MATEMATIKA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL AJAR MATEMATIKA KELAS 6 KURIKULUM MERDEKA.pdf
 
TUGAS RUANG KOLABORASI 1.3 PRAKARSA PERUBAHAN
TUGAS RUANG KOLABORASI 1.3 PRAKARSA PERUBAHANTUGAS RUANG KOLABORASI 1.3 PRAKARSA PERUBAHAN
TUGAS RUANG KOLABORASI 1.3 PRAKARSA PERUBAHAN
 
Prov.Jabar_1504_Pengumuman Seleksi Tahap 2_CGP A11 (2).pdf
Prov.Jabar_1504_Pengumuman Seleksi Tahap 2_CGP A11 (2).pdfProv.Jabar_1504_Pengumuman Seleksi Tahap 2_CGP A11 (2).pdf
Prov.Jabar_1504_Pengumuman Seleksi Tahap 2_CGP A11 (2).pdf
 
PELAKSANAAN (dgn PT SBI) + Link2 Materi Pelatihan _"Teknik Perhitungan TKDN, ...
PELAKSANAAN (dgn PT SBI) + Link2 Materi Pelatihan _"Teknik Perhitungan TKDN, ...PELAKSANAAN (dgn PT SBI) + Link2 Materi Pelatihan _"Teknik Perhitungan TKDN, ...
PELAKSANAAN (dgn PT SBI) + Link2 Materi Pelatihan _"Teknik Perhitungan TKDN, ...
 
TEKNIK MENJAWAB RUMUSAN SPM 2022 - UNTUK MURID.pptx
TEKNIK MENJAWAB RUMUSAN SPM 2022 - UNTUK MURID.pptxTEKNIK MENJAWAB RUMUSAN SPM 2022 - UNTUK MURID.pptx
TEKNIK MENJAWAB RUMUSAN SPM 2022 - UNTUK MURID.pptx
 
PANDUAN PENGEMBANGAN KSP SMA SUMBAR TAHUN 2024 (1).pptx
PANDUAN PENGEMBANGAN KSP SMA SUMBAR TAHUN 2024 (1).pptxPANDUAN PENGEMBANGAN KSP SMA SUMBAR TAHUN 2024 (1).pptx
PANDUAN PENGEMBANGAN KSP SMA SUMBAR TAHUN 2024 (1).pptx
 
PPT MODUL 6 DAN 7 PDGK4105 KELOMPOK.pptx
PPT MODUL 6 DAN 7 PDGK4105 KELOMPOK.pptxPPT MODUL 6 DAN 7 PDGK4105 KELOMPOK.pptx
PPT MODUL 6 DAN 7 PDGK4105 KELOMPOK.pptx
 
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptxPendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
Pendidikan-Bahasa-Indonesia-di-SD MODUL 3 .pptx
 
MODUL PENDIDIKAN PANCASILA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL PENDIDIKAN PANCASILA KELAS 6 KURIKULUM MERDEKA.pdfMODUL PENDIDIKAN PANCASILA KELAS 6 KURIKULUM MERDEKA.pdf
MODUL PENDIDIKAN PANCASILA KELAS 6 KURIKULUM MERDEKA.pdf
 
MODUL AJAR IPAS KELAS 3 KURIKULUM MERDEKA.pdf
MODUL AJAR IPAS KELAS 3 KURIKULUM MERDEKA.pdfMODUL AJAR IPAS KELAS 3 KURIKULUM MERDEKA.pdf
MODUL AJAR IPAS KELAS 3 KURIKULUM MERDEKA.pdf
 
Intellectual Discourse Business in Islamic Perspective - Mej Dr Mohd Adib Abd...
Intellectual Discourse Business in Islamic Perspective - Mej Dr Mohd Adib Abd...Intellectual Discourse Business in Islamic Perspective - Mej Dr Mohd Adib Abd...
Intellectual Discourse Business in Islamic Perspective - Mej Dr Mohd Adib Abd...
 

ikp321-03

  • 1. Manajemen dan Kualitas Perangkat Lunak IKP321 Unit Testing
  • 2. Unit  Perangkat Lunak  Code  Documentation  Procedure  Data  Satuan terkecil Code  Unit  Method atau Function atau Procedure
  • 3. Unit Testing  Test-case untuk Unit  Spesifikasi  Pemanggilan Unit  Ekspektasi luaran yang dihasilkan oleh Unit  Menguji apakah Unit sudah berfungsi sebagaimana yang diharapkan (as expected)  Menguji Unit secara independen, tanpa bergantung pada hasil komputasi Unit lain
  • 4. Rehat Sejenak: Python  Bahasa pemrograman Scripting  Interpreter  Multi platform  Pengguna  Google  NASA  etc.  This class  'Secret Weapon'
  • 5. Python  Dapat diunduh dari  http://www.python.org/getit  Sesuaikan dengan platform komputer masing-masing (Windows, Linux, Mac OS)  Per April 2012, ada dua versi Python  2.7.2  3.2.2  Gunakan versi 2.7.2
  • 6. IDLE  Editor sederhana untuk Python  Bagian dari paket instalasi standar  Start → Python 2.7.2 → IDLE (Python GUI)  Mulai menjalankan Python Shell  File → New Window  Membuka jendela IDLE  File → Save As  "hello.py"  Letakkan di folder yang mudah diingat dan diakses (C:Usersuser)
  • 7. IDLE  Ketik di jendela IDLE  print ("Ini program Python pertamaku.")  Jalankan program  Alt + R → Run Module  Tekan tombol F5
  • 10. Fungsi dan Docstring  Dokumentasi internal dalam program Python  Jendela IDLE  File → New Window  File → Save As  "maxthree.py"  Definisikan sebuah fungsi
  • 12. Fungsi dan Docstring  Docstring mendokumentasikan deskripsi dan spesifikasi sebuah fungsi  Bagian dari dokumentasi online (online help) dalam Python Shell  Jendela Python Shell  import maxthree  help(maxthree)
  • 14. Rehat Selesai: Doctest  Bagian dari Docstring  'Memanggil' fungsi Python sebagai bagian dari test-case  Test case untuk maxthree >>> maxthree(3, 2, 1) 3 >>> maxthree(3, 2, 3) 3 >>> maxthree(-1,-2, -3) -1
  • 16. Menjalankan Doctest  Jalankan dari Command Prompt  python -m doctest maxthree.py
  • 17. Mengimplementasikan Code Fungsi  Doctest dapat dituliskan sebelum body dari fungsi ditulis  Doctest memberikan test-case yang fail  Sebelum code fungsi belum diimplementasikan, semua test-case pasti fail  Doctest memberikan spesifikasi tentang apa yang di- expect dari sebuah fungsi
  • 19. Memeriksa Test-case  Tidak ada test-case yang fail  python -m doctest maxthree.py  Gunakan option -v untuk menampilkan rincian Unit Test  python -m doctest -v maxthree.py
  • 20. Online Help  Docstring terupdate dengan informasi Doctest  Python Shell  reload(maxthree)  help(maxthree)
  • 21. Pustaka  www.python.org/getit/  http://www.annedawson.net/Python_Editor_IDLE.htm  starship.python.net/~tbryan/UnitTestTalk/index.html  tjerdastangkas.blogspot.com/search/label/ikp321