SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
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 Test

   a piece of code
   written by a developer
   executes a specific functionality in the code under test
   Unit tests ensure
   that code is working as intended
   and validate that this is still the case after code changes.
   Menguji apakah Unit sudah berfungsi sebagaimana yang
    diharapkan (as expected)
   Menguji Unit secara independen, tanpa bergantung pada
    hasil komputasi Unit lain
Rehat Sejenak: JUnit

   Package untuk menjalankan Unit Testing di Java
   Dapat diunduh dari
    https://github.com/KentBeck/junit/downloads
   Jar file
    junit-4.10.jar
   Simpan di folder tertentu
    C:jarfilesjunit-4.10.jar
    /usr/share/java/junit-4.10.jar
   Update CLASSPATH environment variable
    Set CLASSPATH=.;C:jarfilesjunit-4.10.jar
    Export CLASSPATH=.:/usr/share/java/junit-4.10.jar
Deklarasi Class Test Case

import junit.framework.*;


public class MaxThreeTest extends TestCase {
    public MaxThreeTest(String name) {
        super(name);
    }


    @Test public void testSimple() {
        assertEquals(9, MaxThree.largest(7, 8, 9));
    }
}
Kompilasi Class Test Case

   CLASSPATH sudah diset
   javac MaxThreeTest.java
   CLASSPATH belum diset
   javac -cp /usr/share/java/junit-4.10.jar
    MaxThreeTest.java
   javac -cp C:jarfilesjunit-4.10.jar MaxThreeTest.java
   Jalankan Test Case
   java junit.textui.TestRunner MaxThreeTest
   java junit.swingui.TestRunner MaxThreeTest
   java org.junit.runner.JUnitCore MaxThreeTest
Kompilasi Class Test Case

.E
Time: 0.043
There was 1 error:
1) testSimple(MaxThreeTest)java.lang.NoClassDefFoundError: MaxThree
    at MaxThreeTest.testSimple(MaxThreeTest.java:13)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
ssorImpl.java:25)
Caused by: java.lang.ClassNotFoundException: MaxThree
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 16 more

FAILURES!!!
Tests run: 1,   Failures: 0,   Errors: 1
Implementasi Class

public class MaxThree {
  /**
   * Return the largest element from 3 integers.
   *
   * @param a,b,c Three integers
   * @return The largest number between inputs.
   */


  public static int largest(int a, int b, int c) {
    int max;
Implementasi Class

        if (a >= b) {
            max = a;
        } else {
            max = b;
        }
        if (c >= max) {
            max = c;
        }


        return max;
    }
}
●Jalankan Test Case

   java junit.textui.TestRunner MaxThreeTest
   java junit.swingui.TestRunner MaxThreeTest
   java org.junit.runner.JUnitCore MaxThreeTest
   Hasil
    JUnit version 4.10
    .
    Time: 0.005


    OK (1 test)
JUnit dan Eclipse

   Eclipse IDE for Java
    Developers
        http://www.eclipse.org/
         downloads/
   Unduh, Pasang, dan
    Jalankan
   Buat Java Project yang
    baru
JUnit dan Eclipse
JUnit dan Eclipse

   Klik-kanan src, pilih New,
    pilih Class
   Tuliskan nama class
        MyClass
JUnit dan Eclipse
JUnit dan Eclipse

   Klik-kanan pada Class
    yang baru dibuat
   Pilih New, pilih Junit Test
    Case
   Pilih opsi "New JUnit 4
    test"
   Ubah nama folder ke
    folder "test"
JUnit dan Eclipse

   Pilih nama method yang
    perlu dibuat Test Case-
    nya
JUnit dan Eclipse

   Tambahkan class JUnit ke
    dalam path Project
JUnit dan Eclipse
JUnit dan Eclipse

   Klik-kanan pada Class
    Test Case,
   Pilih Run As,
   Pilih JUnit test
JUnit dan Eclipse
Pustaka

   http://www.vogella.de/articles/JUnit/article.html
   starship.python.net/~tbryan/UnitTestTalk/index.html
   tjerdastangkas.blogspot.com/search/label/ikp321

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

TestNG with selenium
TestNG with seleniumTestNG with selenium
TestNG with selenium
 
TestNg_Overview_Config
TestNg_Overview_ConfigTestNg_Overview_Config
TestNg_Overview_Config
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
TestNG
TestNGTestNG
TestNG
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Junit
JunitJunit
Junit
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
Test ng for testers
Test ng for testersTest ng for testers
Test ng for testers
 
Junit
JunitJunit
Junit
 
Junit
JunitJunit
Junit
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practices
 
Test ng
Test ngTest ng
Test ng
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 

Andere mochten auch

Ifmasv Roundtable Sj City College09 May12
Ifmasv Roundtable   Sj City College09 May12Ifmasv Roundtable   Sj City College09 May12
Ifmasv Roundtable Sj City College09 May12AndyFuhrman
 
Odyssey Nov 2008
Odyssey Nov 2008Odyssey Nov 2008
Odyssey Nov 2008jhibbs
 
Plan estratgicoparalaspersonasconte aysusfamilias
Plan estratgicoparalaspersonasconte aysusfamiliasPlan estratgicoparalaspersonasconte aysusfamilias
Plan estratgicoparalaspersonasconte aysusfamiliasPepe Jara Cueva
 
Bolsafotos
BolsafotosBolsafotos
BolsafotosSkipje
 
Capsule01 Creds2008
Capsule01 Creds2008Capsule01 Creds2008
Capsule01 Creds2008capsule01
 
Agency User Guide
Agency User GuideAgency User Guide
Agency User Guidemayureshp
 
La coruña
La coruñaLa coruña
La coruñaC FM
 
Orange Language Travel Guide
Orange Language Travel GuideOrange Language Travel Guide
Orange Language Travel GuideOrange BG
 
Acrp Presentation Jan 2009
Acrp Presentation Jan 2009Acrp Presentation Jan 2009
Acrp Presentation Jan 2009thess1121
 
Osam Mardin Professional Samples1
Osam Mardin Professional Samples1Osam Mardin Professional Samples1
Osam Mardin Professional Samples1mardinor
 
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...LINKInnovationStudies
 
Facebook for Business (Creating Fan Pages)
Facebook for Business (Creating Fan Pages)Facebook for Business (Creating Fan Pages)
Facebook for Business (Creating Fan Pages)CreAgent Marketing
 
Black friday haine
Black friday haineBlack friday haine
Black friday haineDa Vinci
 
Crowdfunding 101
Crowdfunding 101Crowdfunding 101
Crowdfunding 101Dave Gee
 
B2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxB2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxAngelo Corsaro
 
Ingalaterra Eta Portugal
Ingalaterra Eta PortugalIngalaterra Eta Portugal
Ingalaterra Eta Portugalguestd4e08
 

Andere mochten auch (20)

Ifmasv Roundtable Sj City College09 May12
Ifmasv Roundtable   Sj City College09 May12Ifmasv Roundtable   Sj City College09 May12
Ifmasv Roundtable Sj City College09 May12
 
Odyssey Nov 2008
Odyssey Nov 2008Odyssey Nov 2008
Odyssey Nov 2008
 
Sph 106 Ch 10
Sph 106 Ch 10Sph 106 Ch 10
Sph 106 Ch 10
 
Plan estratgicoparalaspersonasconte aysusfamilias
Plan estratgicoparalaspersonasconte aysusfamiliasPlan estratgicoparalaspersonasconte aysusfamilias
Plan estratgicoparalaspersonasconte aysusfamilias
 
Bolsafotos
BolsafotosBolsafotos
Bolsafotos
 
Vagrant
VagrantVagrant
Vagrant
 
Capsule01 Creds2008
Capsule01 Creds2008Capsule01 Creds2008
Capsule01 Creds2008
 
Agency User Guide
Agency User GuideAgency User Guide
Agency User Guide
 
La coruña
La coruñaLa coruña
La coruña
 
Orange Language Travel Guide
Orange Language Travel GuideOrange Language Travel Guide
Orange Language Travel Guide
 
presentacion
presentacionpresentacion
presentacion
 
Acrp Presentation Jan 2009
Acrp Presentation Jan 2009Acrp Presentation Jan 2009
Acrp Presentation Jan 2009
 
Osam Mardin Professional Samples1
Osam Mardin Professional Samples1Osam Mardin Professional Samples1
Osam Mardin Professional Samples1
 
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...
Beyond Europe: Priorities for Strengthening Agricultural Innovation Capacity ...
 
5 A 2008
5 A  20085 A  2008
5 A 2008
 
Facebook for Business (Creating Fan Pages)
Facebook for Business (Creating Fan Pages)Facebook for Business (Creating Fan Pages)
Facebook for Business (Creating Fan Pages)
 
Black friday haine
Black friday haineBlack friday haine
Black friday haine
 
Crowdfunding 101
Crowdfunding 101Crowdfunding 101
Crowdfunding 101
 
B2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxB2: The OpenSplice BlendBox
B2: The OpenSplice BlendBox
 
Ingalaterra Eta Portugal
Ingalaterra Eta PortugalIngalaterra Eta Portugal
Ingalaterra Eta Portugal
 

Ähnlich wie ikp321-04

Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightOpenDaylight
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringromanovfedor
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactusHimanshu
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAhmed Ehab AbdulAziz
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnitGreg.Helton
 
A fresh look at Java Enterprise Application testing with Arquillian
A fresh look at Java Enterprise Application testing with ArquillianA fresh look at Java Enterprise Application testing with Arquillian
A fresh look at Java Enterprise Application testing with ArquillianVineet Reynolds
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxKnoldus Inc.
 

Ähnlich wie ikp321-04 (20)

8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
Junit With Eclipse
Junit With EclipseJunit With Eclipse
Junit With Eclipse
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
3 j unit
3 j unit3 j unit
3 j unit
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discovering
 
Unit test
Unit testUnit test
Unit test
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
 
L08 Unit Testing
L08 Unit TestingL08 Unit Testing
L08 Unit Testing
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
A fresh look at Java Enterprise Application testing with Arquillian
A fresh look at Java Enterprise Application testing with ArquillianA fresh look at Java Enterprise Application testing with Arquillian
A fresh look at Java Enterprise Application testing with Arquillian
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptx
 

Mehr von 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-03
ikp321-03ikp321-03
ikp321-03
 

Kürzlich hochgeladen

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 

Kürzlich hochgeladen (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

ikp321-04

  • 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 Test  a piece of code  written by a developer  executes a specific functionality in the code under test  Unit tests ensure  that code is working as intended  and validate that this is still the case after code changes.  Menguji apakah Unit sudah berfungsi sebagaimana yang diharapkan (as expected)  Menguji Unit secara independen, tanpa bergantung pada hasil komputasi Unit lain
  • 4. Rehat Sejenak: JUnit  Package untuk menjalankan Unit Testing di Java  Dapat diunduh dari  https://github.com/KentBeck/junit/downloads  Jar file  junit-4.10.jar  Simpan di folder tertentu  C:jarfilesjunit-4.10.jar  /usr/share/java/junit-4.10.jar  Update CLASSPATH environment variable  Set CLASSPATH=.;C:jarfilesjunit-4.10.jar  Export CLASSPATH=.:/usr/share/java/junit-4.10.jar
  • 5. Deklarasi Class Test Case import junit.framework.*; public class MaxThreeTest extends TestCase { public MaxThreeTest(String name) { super(name); } @Test public void testSimple() { assertEquals(9, MaxThree.largest(7, 8, 9)); } }
  • 6. Kompilasi Class Test Case  CLASSPATH sudah diset  javac MaxThreeTest.java  CLASSPATH belum diset  javac -cp /usr/share/java/junit-4.10.jar MaxThreeTest.java  javac -cp C:jarfilesjunit-4.10.jar MaxThreeTest.java  Jalankan Test Case  java junit.textui.TestRunner MaxThreeTest  java junit.swingui.TestRunner MaxThreeTest  java org.junit.runner.JUnitCore MaxThreeTest
  • 7. Kompilasi Class Test Case .E Time: 0.043 There was 1 error: 1) testSimple(MaxThreeTest)java.lang.NoClassDefFoundError: MaxThree at MaxThreeTest.testSimple(MaxThreeTest.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl .java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce ssorImpl.java:25) Caused by: java.lang.ClassNotFoundException: MaxThree at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 16 more FAILURES!!! Tests run: 1, Failures: 0, Errors: 1
  • 8. Implementasi Class public class MaxThree { /** * Return the largest element from 3 integers. * * @param a,b,c Three integers * @return The largest number between inputs. */ public static int largest(int a, int b, int c) { int max;
  • 9. Implementasi Class if (a >= b) { max = a; } else { max = b; } if (c >= max) { max = c; } return max; } }
  • 10. ●Jalankan Test Case  java junit.textui.TestRunner MaxThreeTest  java junit.swingui.TestRunner MaxThreeTest  java org.junit.runner.JUnitCore MaxThreeTest  Hasil JUnit version 4.10 . Time: 0.005 OK (1 test)
  • 11. JUnit dan Eclipse  Eclipse IDE for Java Developers  http://www.eclipse.org/ downloads/  Unduh, Pasang, dan Jalankan  Buat Java Project yang baru
  • 13. JUnit dan Eclipse  Klik-kanan src, pilih New, pilih Class  Tuliskan nama class  MyClass
  • 15. JUnit dan Eclipse  Klik-kanan pada Class yang baru dibuat  Pilih New, pilih Junit Test Case  Pilih opsi "New JUnit 4 test"  Ubah nama folder ke folder "test"
  • 16. JUnit dan Eclipse  Pilih nama method yang perlu dibuat Test Case- nya
  • 17. JUnit dan Eclipse  Tambahkan class JUnit ke dalam path Project
  • 19. JUnit dan Eclipse  Klik-kanan pada Class Test Case,  Pilih Run As,  Pilih JUnit test
  • 21. Pustaka  http://www.vogella.de/articles/JUnit/article.html  starship.python.net/~tbryan/UnitTestTalk/index.html  tjerdastangkas.blogspot.com/search/label/ikp321