SlideShare a Scribd company logo
1 of 32
1© Vahid Garousi
Yazılım Test-Kod Mühendisliği (YTKM):
Kaliteli Test-Kodu Geliştirmek, Doğrulamak ve Bakımı
Software Test-Code Engineering (STCE):
Developing, verifying and maintaining high-quality test scripts
Doç. Dr. Vahid Garousi
Associate Professor of Software Engineering
Senior Software Consultant
vahid.garousi@hacettepe.edu.tr
http://web.cs.hacettepe.edu.tr/~vahid
vgarousi
Yazılım Mühendisliği Araştırma Grubu (HUSE)
Bilgisayar Mühendisliği Bölümü
Hacettepe Üniversitesi
2© Vahid Garousi
Sunum İçeriği
 Duyuru: Hacettepe Üniversitesinde "Yazılım Test Mühendisliği"
dersi. Endüstriden gelen mühendislere açık
 Test-koduna genel bir bakış
 Birkaç örnek
 Test-kodunun kalitesi neden önemlidir?
 Test-kodu yaşam döngüsü ve test-kod mühendisliği
 Nasıl?
 Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)
 Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)
 TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co-
maintaining test scripts with the SUT)
 Ne öğreneceğiz?
 Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
3© Vahid Garousi
Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
 Pratik-yoğun (hands-on) bir ders
 Tarihçe:
 Kanada’da 10 sene civarı hem üniversite ve hem de endüstriye verilen
ders
 Türkiye'de ODTÜ ve Atılım Üniversitesin de verildi, endüstriden birçok
katılım oldu
 Beş proje:
 Introduction to Testing, Bug Reporting and Defect Tracking
 Black-box Testing and API-Based Unit Testing using JUnit
 Code Coverage and White-box Testing in JUnit
 Automated Web Application Testing using Selenium
 Using Static Analysis to Find Bugs
4© Vahid Garousi
Lab 1: Introduction to Testing and Defect Tracking
 Goals:
 Getting hands-on experience in ad-hoc, manual and regression testing
 Using industrial defect tracking practices and tools
 Experiencing that ad-hoc manual testing is not always very effective
 SUT: An ATM simulation system
 Testing support tool: JIRA, Bugzilla, the Google issue tracking tool
 Realistic defects were manually injected in the SUT
5© Vahid Garousi
Lab 1: Introduction to Testing and Defect Tracking
 Lab document (instructions)…
 Extensive effort was spent to
prepare realistic, clear, concise and
“interesting” lab exercises…
 We involved several test engineers
from the industry
6© Vahid Garousi
Lab 1: Introduction to Testing and Defect Tracking
Report bugs to
7© Vahid Garousi
 Lab 2: Black-box Testing and API-Based Unit Testing using JUnit
 SUT: JFreeChart
 Testing tool: JUnit
Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
8© Vahid Garousi
 Students applied the equivalence partitioning technique based on
Javadoc API Specifications
Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
9© Vahid Garousi
Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
 2015 güz döneminde açılacaktır
 Dünyanın birçok ülkesinde bu ders materyali kullanılmış
10© Vahid Garousi
Sunum içeriği
 Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
 Test-koduna genel bir bakış
 Birkaç örnek
 Test-kodunun kalitesi neden önemlidir?
 Test-kodu yaşam döngüsü ve test-kod mühendisliği
 Nasıl?
 Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)
 Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)
 TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co-
maintaining test scripts with the SUT)
 Ne öğreneceğiz?
 Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
11© Vahid Garousi
Test-Koduna Genel Bir Bakış
 Birkaç örnek
 Sistem seviyesinde bir test
 Selenium web uygulamaları
test aracı
TED (Test Edilen Yazılım)
12© Vahid Garousi
Otomatik Test Altyapıları Çok Büyük Ölçütlere Gelmişler
 "Sistemin kendisinden muhtemelen daha karmaşık bir test
sistemi tasarladık."
 “We designed a test system that probably is as complicated as
the system itself.”
Jeff Feldstein, Manager, Software Development
Cisco Systems, San Jose, California
Google Tech Talks, November 9, 2005
(a very good talk)
 "Microsoft Office 2007 için, bir
milyondan fazla otomatik test senaryosu
geliştirilirmiştir."
13© Vahid Garousi
Test-Kodunun Kalitesinde Sorunlar
 Senaryo:
 İki önemli olan doğrulama
adımından birisinin
(verifyTextPresent) yazılması
unutulmuş
 Sorun:
 Böylece TEY’da bu konuda
hata olursa eğer, bu test o
hatayı yakalamayacaktır.
 Ders:
 Acaba, test mühendislerimiz
kaliteli test-kod geliştiriyorlar
mı?
 Test-kod kalitesi normal
kaynak kod kalitesi gibi
önemlidir
14© Vahid Garousi
Test-Koduna Genel Bir Bakış
 Başka bir örnek
 Birim seviyesinde bir test
(unit test)
TED (Test Edilen Yazılım):
Java için bir loglama kütüphanesi
15© Vahid Garousi
Test-Koduna Genel Bir Bakış
 Durum:
 Üç test fonksiyonu mevcut
 Üçüncü fonksiyonda önemli olan
doğrulama noktası (assertion)
mevcut
 Sorun:
 Ama ilk iki test fonksiyonunda
doğrulama noktalarının yazılması
unutulmuş
 Eksik gibi?
 Böylece TEY’da hata varsa eğer,
bu testler o hatayı
yakalamayacaktır.
 Ders:
 Acaba, testlerimizde yeterli
doğrulama noktaları (assertion)
var mi?
 Bu doğrulamalar aslında testlerin
(hata bulmak) gücüdür
16© Vahid Garousi
Test otomasyonunda Test-Kod Yaşam Döngüsü
 Yazılım Test-Kod Mühendisliği (YTKM): Mühendislik ve sistematik
yöntemleri kullanarak bu adımları en verimli şekilde yapmak
Test aracı
Test kodu
geliştirilmesi
Ürün kodu
bakımı
Otomatik test
kodu geliştirme
Test kodunun elle
geliştirilmesi
Yazılım
Test
Muhendisi
Ürün kodu
geliştirilme
Test kodu eş-
bakımı
kullanıyor
İzlenebilirlik bağlantılar
Test Edilen
Yazılım
(TEY)
Otomatik
Test Küme
Kalite
değerlendirme
İzlenebilirlik
bağlantılar
etkiliyoretkiliyor
Kalite
değerlendirme
kullanılıyor
Kalite iyileştirme
Kalite iyileştirme
17© Vahid Garousi
Test-Kodu Mühendisliğine Dünyada Verilen Önem
18© Vahid Garousi
Sunum içeriği
 Hacettepe Üniversitesinde Yazılım Test Mühendisliği dersi
 Test-koduna genel bir bakış
 Birkaç örnek
 Test-kodunun kalitesi neden önemlidir?
 Test-kodu yaşam döngüsü ve test-kod mühendisliği
 Nasıl?
 Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)
 Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)
 TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co-
maintaining test scripts with the SUT)
 Ne öğreneceğiz?
 Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
19© Vahid Garousi
Kaliteli Test-Kodu Nasıl Geliştirilir?
 Manuel yöntem: test mühendisi el ile test kodu yazıyor
 Normal kaynak kodu gibi, kaliteli kod yazmak lazım
 Birçok önemli noktaya dikkat lazım
 Test kodunun kalite yönleri ve ölçütleri nelerdir?
 Test kodunun hem fonksiyonel (functional) ve hem fonksiyonel-dışı
(non-functional) kalite yönleri vardır.
 Fonksiyonel kalite: test kodunun ürün kodunu doğru ve sağlam test
etmesidir.
 Meşhur “Saatçiyi izlemek”(İngilizcede: “Watching the watchman”) sözü
gibi, test kodu için de dikkatli doğrulama ve geçerleme lazım.
 Test kodunun fonksiyonel-dışı kalitesi ise, “-bilirlik” ailesindeki kalite
ölçütlerini kapsıyor, örneğin, bakıla-bilirlik (maintainability), anlaya-bilirlik
(understandability) ve güvene-bilirlik (reliability).
20© Vahid Garousi
Kaliteli Test-Kodu Nasıl Geliştirilir?
 Çözüm: Test örüntüleri (Test patterns)
 "Tasarım örüntülerine" (design patterns) benziyorlar
 Örnek test örüntüleri:
 Sayfa Nesneleri (Page objects): The Page Object pattern represents the screens of your
web app as a series of objects
 Web uygulamalarını otomatik test ederken, kullanıcı arayüzünde (UI) testler ile etkileşim
alanları vardır.
 Bir "Sayfa Nesnesi" test kodunun içinde tum sayfayı nesne olarak modelliyor.
 Böylece, kopya kod miktarı azalıyor ve arayüz değişirse, düzeltme, test içinde değişikler
yalnızca tek bir yerde gerekiyor.
 Örnek: bir web-tabanlı email uygulamayı test ederken:
 Yerine:
 Daha çok örnek: https://code.google.com/p/selenium/wiki/PageObjects
21© Vahid Garousi
Kaliteli Test-Kod: Test Örüntüler
 Örnek test otomasyon aracı: Selenium
 Çözüm: Test örüntüleri (Test patterns)
 Ayrıntılar:
22© Vahid Garousi
Kaliteli Test-Kodu: Birim testinde otomasyon
 Test otomasyon altyapısı: JUnit (birim test için)
 Örnek bir JUnit birim test kodu:
 Android işletim sistemi kodundan: Acil numara (911) ayarının düzgün ayarlanmış
olup olmadığını kontrol etmek
23© Vahid Garousi
Kaliteli Test-Kodu: Test Örüntüleri
 Test otomasyon altyapısı: JUnit
 Birim testi için test örüntüleri, örnekler:
 Test mantığımızı net bir şekilde yazmak için, testlerimizi nasıl bir yapıda
oluşturmalıyız?
 Öneri: testleri sırayla dört farklı adımda yapılandırmak
 Dört-Adım Testi (Four-Phase Test)
24© Vahid Garousi
Kaliteli Test-Kodu: Test Örüntüleri
 Dört-Adım Testi (Four-Phase Test)
 Faydalar:
 Bakıla-bilirlik (maintainability)
 Anlaya-bilirlik (understandability)
 Modülerlik (modularity)
25© Vahid Garousi
Kaliteli Test-Kodu: Test Örüntüleri
 Birim testi için test örüntüleri
 Ayrıntılar ve daha çok test örüntüsü:
26© Vahid Garousi
Testleri Otomatik Üretmek
 Manuel yöntem: test mühendisi el ile test kodu yazıyor
 Otomatik yöntem: bir test otomasyon aracı kullanarak test kodu otomatik bir şekilde
geliştirmek
 Tekrar, farklı test seviyeleri için (birim ve sistem testi), farklı araçlar mevcut
27© Vahid Garousi
Testleri Otomatik Üretmek
 Bir projeden örnek
 Firma:
 .Net’de NUnit testlerini otomatik üretmek
 Test Edilen Yazılım (TEY): Rocket adlı bir Veri Tabanlı Kontrol ve Gözetleme
Sistemi (Supervisory Control and Data Acquisition (SCADA)
 Sıkıntı: Manuel şekilde NUnit testleri geliştirmek çok zaman alıyordu, örneğin:
denklik sınıflandırma (equivalence classing) metodun kullanarak, bu sistemde,
19,683 tane test senaryosu sadece bir birim (fonksiyon blok) için çıkıyordu. Kotu
haber  (bu kadar test kodu yazmak çok efor istiyor)
28© Vahid Garousi
Testleri Otomatik Üretmek
 .Net’de NUnit testlerini otomatik üretmek
İkili test
Programın tüm ikili girdi kombinasyonlarını çalıştırmak
için test senaryolarının tasarlandığı kara kutu test
tasarım tekniği Ayrıca bakınız dikey dizi testi.
A black box test design technique in which test cases
are designed to execute all possible discrete
combinations of each pair of input parameters. See also
orthogonal array testing.
29© Vahid Garousi
İkili Test (Pair-Wise Testing): Bir örnek
 Deneysel çalışmalardan: “Hatalar genelde sadece birkaç değişken
etkileşimi sebebiyle yaratılıyorlar, böylece sadece birkaç değişkenin
etkileşimlerini kontrol eden testler hataları bulmakta çok etkin
olmaktadır."
 "Failures appear to be caused by interactions of only a few variables, so tests
that cover all such few-variable interactions can be very effective.”
 Örnek:
 3 değişken
 3 != 6 test senaryosu
 Ama sadece bir test senaryo
hatayı bulacaktır:
 pressure<10
 volume>300
 Ve o senaryo, iyi değişkeninin
etkileşimine aittir
30© Vahid Garousi
İkili test: Deneysel çalışmalardan
sonuçlar
(Pair-Wise Testing): Results from Empirical Studies
Değişkenlerin etkileşim sayısı
Kümülatif
yüzde
31© Vahid Garousi
Testleri Otomatik Üretmek
 .Net’de NUnit testleri otomatik üretmek
32© Vahid Garousi
Sunum İçeriği
 Test-koduna genel bir bakış
 Birkaç örnek
 Test-kodunun kalitesi neden önemlidir?
 Test-kodu yaşam döngüsü ve test-kod mühendisliği (YTKM)
 Nasıl?
 Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)
 Test-kodu kalitelisini doğrulayalım (Verifying test scripts)
 TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım
(Co-maintaining test scripts with the SUT)
 Ne öğrendik?
 Bu alanda, birkaç teknik, araçlar ve deneyimleri gözden geçireceğiz
Bugün
Sonra

More Related Content

More from Vahid Garousi

Next level of test automation with Model-based Testing (MBT): Experience and ...
Next level of test automation with Model-based Testing (MBT): Experience and ...Next level of test automation with Model-based Testing (MBT): Experience and ...
Next level of test automation with Model-based Testing (MBT): Experience and ...Vahid Garousi
 
Slides for for JSS "Happy Hour": Aligning software engineering education with...
Slides for for JSS "Happy Hour": Aligning software engineering education with...Slides for for JSS "Happy Hour": Aligning software engineering education with...
Slides for for JSS "Happy Hour": Aligning software engineering education with...Vahid Garousi
 
Experience in conducting 19 secondary (survey) studies in Software Engineering
Experience in conducting 19 secondary (survey) studies in Software EngineeringExperience in conducting 19 secondary (survey) studies in Software Engineering
Experience in conducting 19 secondary (survey) studies in Software EngineeringVahid Garousi
 
Sustainability of Scientific Software: Experience from Several Projects
Sustainability of Scientific Software: Experience from Several ProjectsSustainability of Scientific Software: Experience from Several Projects
Sustainability of Scientific Software: Experience from Several ProjectsVahid Garousi
 
Career paths, training and learning resources in software test engineering
Career paths, training and learning resources in software test engineeringCareer paths, training and learning resources in software test engineering
Career paths, training and learning resources in software test engineeringVahid Garousi
 
Industry-academia collaborations in software testing: Success stories from Ca...
Industry-academia collaborations in software testing: Success stories from Ca...Industry-academia collaborations in software testing: Success stories from Ca...
Industry-academia collaborations in software testing: Success stories from Ca...Vahid Garousi
 
An overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in AndroidAn overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in AndroidVahid Garousi
 
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...Vahid Garousi
 
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...Vahid Garousi
 
Can we do it better? Improving the maturity of software testing in test teams
Can we do it better? Improving the maturity of software testing in test teamsCan we do it better? Improving the maturity of software testing in test teams
Can we do it better? Improving the maturity of software testing in test teamsVahid Garousi
 
Deciding what and when to automate in testing: Experience from multiple projects
Deciding what and when to automate in testing: Experience from multiple projectsDeciding what and when to automate in testing: Experience from multiple projects
Deciding what and when to automate in testing: Experience from multiple projectsVahid Garousi
 
Engineering software systems for improving the operational efficiency of oil ...
Engineering software systems for improving the operational efficiency of oil ...Engineering software systems for improving the operational efficiency of oil ...
Engineering software systems for improving the operational efficiency of oil ...Vahid Garousi
 
Introducing automated GUI testing and observing its benefits: an industrial c...
Introducing automated GUI testing and observing its benefits: an industrial c...Introducing automated GUI testing and observing its benefits: an industrial c...
Introducing automated GUI testing and observing its benefits: an industrial c...Vahid Garousi
 
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...Vahid Garousi
 
An Open Modern Software Testing Laboratory Courseware: An Experience Report
An Open Modern Software Testing Laboratory Courseware: An Experience ReportAn Open Modern Software Testing Laboratory Courseware: An Experience Report
An Open Modern Software Testing Laboratory Courseware: An Experience ReportVahid Garousi
 
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...Vahid Garousi
 
Software engineering of scientific software
Software engineering of scientific softwareSoftware engineering of scientific software
Software engineering of scientific softwareVahid Garousi
 
Vahid Garousi-SE meets robotics
Vahid Garousi-SE meets roboticsVahid Garousi-SE meets robotics
Vahid Garousi-SE meets roboticsVahid Garousi
 
Industry-academia collaborations in software engineering research: Experience...
Industry-academia collaborations in software engineering research: Experience...Industry-academia collaborations in software engineering research: Experience...
Industry-academia collaborations in software engineering research: Experience...Vahid Garousi
 
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...Vahid Garousi
 

More from Vahid Garousi (20)

Next level of test automation with Model-based Testing (MBT): Experience and ...
Next level of test automation with Model-based Testing (MBT): Experience and ...Next level of test automation with Model-based Testing (MBT): Experience and ...
Next level of test automation with Model-based Testing (MBT): Experience and ...
 
Slides for for JSS "Happy Hour": Aligning software engineering education with...
Slides for for JSS "Happy Hour": Aligning software engineering education with...Slides for for JSS "Happy Hour": Aligning software engineering education with...
Slides for for JSS "Happy Hour": Aligning software engineering education with...
 
Experience in conducting 19 secondary (survey) studies in Software Engineering
Experience in conducting 19 secondary (survey) studies in Software EngineeringExperience in conducting 19 secondary (survey) studies in Software Engineering
Experience in conducting 19 secondary (survey) studies in Software Engineering
 
Sustainability of Scientific Software: Experience from Several Projects
Sustainability of Scientific Software: Experience from Several ProjectsSustainability of Scientific Software: Experience from Several Projects
Sustainability of Scientific Software: Experience from Several Projects
 
Career paths, training and learning resources in software test engineering
Career paths, training and learning resources in software test engineeringCareer paths, training and learning resources in software test engineering
Career paths, training and learning resources in software test engineering
 
Industry-academia collaborations in software testing: Success stories from Ca...
Industry-academia collaborations in software testing: Success stories from Ca...Industry-academia collaborations in software testing: Success stories from Ca...
Industry-academia collaborations in software testing: Success stories from Ca...
 
An overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in AndroidAn overview of automated test suites and defect density in Android
An overview of automated test suites and defect density in Android
 
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...
inforte.fi invited talk-Day 2: Conducting industry-relevant software enginee...
 
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...
inforte.fi invited talk-Day 1: Conducting industry-relevant software engineer...
 
Can we do it better? Improving the maturity of software testing in test teams
Can we do it better? Improving the maturity of software testing in test teamsCan we do it better? Improving the maturity of software testing in test teams
Can we do it better? Improving the maturity of software testing in test teams
 
Deciding what and when to automate in testing: Experience from multiple projects
Deciding what and when to automate in testing: Experience from multiple projectsDeciding what and when to automate in testing: Experience from multiple projects
Deciding what and when to automate in testing: Experience from multiple projects
 
Engineering software systems for improving the operational efficiency of oil ...
Engineering software systems for improving the operational efficiency of oil ...Engineering software systems for improving the operational efficiency of oil ...
Engineering software systems for improving the operational efficiency of oil ...
 
Introducing automated GUI testing and observing its benefits: an industrial c...
Introducing automated GUI testing and observing its benefits: an industrial c...Introducing automated GUI testing and observing its benefits: an industrial c...
Introducing automated GUI testing and observing its benefits: an industrial c...
 
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...
Working with Students to Co-design and Enhance Realistic (Modern) Exercises f...
 
An Open Modern Software Testing Laboratory Courseware: An Experience Report
An Open Modern Software Testing Laboratory Courseware: An Experience ReportAn Open Modern Software Testing Laboratory Courseware: An Experience Report
An Open Modern Software Testing Laboratory Courseware: An Experience Report
 
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...
Choosing the Right Testing Tools and Systems Under Test (SUTs) for Practical ...
 
Software engineering of scientific software
Software engineering of scientific softwareSoftware engineering of scientific software
Software engineering of scientific software
 
Vahid Garousi-SE meets robotics
Vahid Garousi-SE meets roboticsVahid Garousi-SE meets robotics
Vahid Garousi-SE meets robotics
 
Industry-academia collaborations in software engineering research: Experience...
Industry-academia collaborations in software engineering research: Experience...Industry-academia collaborations in software engineering research: Experience...
Industry-academia collaborations in software engineering research: Experience...
 
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...
Üniversite Yazılım Mühendisliği programları müfredatının SWEBOK kılavuzu kull...
 

Yazılım Test-Kod Mühendisliği (YTKM): Kaliteli Test-Kodu Geliştirmek, Doğrulamak ve Bakımı / Software Test-Code Engineering (STCE): Developing, verifying and maintaining high-quality test scripts

  • 1. 1© Vahid Garousi Yazılım Test-Kod Mühendisliği (YTKM): Kaliteli Test-Kodu Geliştirmek, Doğrulamak ve Bakımı Software Test-Code Engineering (STCE): Developing, verifying and maintaining high-quality test scripts Doç. Dr. Vahid Garousi Associate Professor of Software Engineering Senior Software Consultant vahid.garousi@hacettepe.edu.tr http://web.cs.hacettepe.edu.tr/~vahid vgarousi Yazılım Mühendisliği Araştırma Grubu (HUSE) Bilgisayar Mühendisliği Bölümü Hacettepe Üniversitesi
  • 2. 2© Vahid Garousi Sunum İçeriği  Duyuru: Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi. Endüstriden gelen mühendislere açık  Test-koduna genel bir bakış  Birkaç örnek  Test-kodunun kalitesi neden önemlidir?  Test-kodu yaşam döngüsü ve test-kod mühendisliği  Nasıl?  Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)  Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)  TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co- maintaining test scripts with the SUT)  Ne öğreneceğiz?  Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
  • 3. 3© Vahid Garousi Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi  Pratik-yoğun (hands-on) bir ders  Tarihçe:  Kanada’da 10 sene civarı hem üniversite ve hem de endüstriye verilen ders  Türkiye'de ODTÜ ve Atılım Üniversitesin de verildi, endüstriden birçok katılım oldu  Beş proje:  Introduction to Testing, Bug Reporting and Defect Tracking  Black-box Testing and API-Based Unit Testing using JUnit  Code Coverage and White-box Testing in JUnit  Automated Web Application Testing using Selenium  Using Static Analysis to Find Bugs
  • 4. 4© Vahid Garousi Lab 1: Introduction to Testing and Defect Tracking  Goals:  Getting hands-on experience in ad-hoc, manual and regression testing  Using industrial defect tracking practices and tools  Experiencing that ad-hoc manual testing is not always very effective  SUT: An ATM simulation system  Testing support tool: JIRA, Bugzilla, the Google issue tracking tool  Realistic defects were manually injected in the SUT
  • 5. 5© Vahid Garousi Lab 1: Introduction to Testing and Defect Tracking  Lab document (instructions)…  Extensive effort was spent to prepare realistic, clear, concise and “interesting” lab exercises…  We involved several test engineers from the industry
  • 6. 6© Vahid Garousi Lab 1: Introduction to Testing and Defect Tracking Report bugs to
  • 7. 7© Vahid Garousi  Lab 2: Black-box Testing and API-Based Unit Testing using JUnit  SUT: JFreeChart  Testing tool: JUnit Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
  • 8. 8© Vahid Garousi  Students applied the equivalence partitioning technique based on Javadoc API Specifications Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi
  • 9. 9© Vahid Garousi Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi  2015 güz döneminde açılacaktır  Dünyanın birçok ülkesinde bu ders materyali kullanılmış
  • 10. 10© Vahid Garousi Sunum içeriği  Hacettepe Üniversitesinde "Yazılım Test Mühendisliği" dersi  Test-koduna genel bir bakış  Birkaç örnek  Test-kodunun kalitesi neden önemlidir?  Test-kodu yaşam döngüsü ve test-kod mühendisliği  Nasıl?  Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)  Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)  TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co- maintaining test scripts with the SUT)  Ne öğreneceğiz?  Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
  • 11. 11© Vahid Garousi Test-Koduna Genel Bir Bakış  Birkaç örnek  Sistem seviyesinde bir test  Selenium web uygulamaları test aracı TED (Test Edilen Yazılım)
  • 12. 12© Vahid Garousi Otomatik Test Altyapıları Çok Büyük Ölçütlere Gelmişler  "Sistemin kendisinden muhtemelen daha karmaşık bir test sistemi tasarladık."  “We designed a test system that probably is as complicated as the system itself.” Jeff Feldstein, Manager, Software Development Cisco Systems, San Jose, California Google Tech Talks, November 9, 2005 (a very good talk)  "Microsoft Office 2007 için, bir milyondan fazla otomatik test senaryosu geliştirilirmiştir."
  • 13. 13© Vahid Garousi Test-Kodunun Kalitesinde Sorunlar  Senaryo:  İki önemli olan doğrulama adımından birisinin (verifyTextPresent) yazılması unutulmuş  Sorun:  Böylece TEY’da bu konuda hata olursa eğer, bu test o hatayı yakalamayacaktır.  Ders:  Acaba, test mühendislerimiz kaliteli test-kod geliştiriyorlar mı?  Test-kod kalitesi normal kaynak kod kalitesi gibi önemlidir
  • 14. 14© Vahid Garousi Test-Koduna Genel Bir Bakış  Başka bir örnek  Birim seviyesinde bir test (unit test) TED (Test Edilen Yazılım): Java için bir loglama kütüphanesi
  • 15. 15© Vahid Garousi Test-Koduna Genel Bir Bakış  Durum:  Üç test fonksiyonu mevcut  Üçüncü fonksiyonda önemli olan doğrulama noktası (assertion) mevcut  Sorun:  Ama ilk iki test fonksiyonunda doğrulama noktalarının yazılması unutulmuş  Eksik gibi?  Böylece TEY’da hata varsa eğer, bu testler o hatayı yakalamayacaktır.  Ders:  Acaba, testlerimizde yeterli doğrulama noktaları (assertion) var mi?  Bu doğrulamalar aslında testlerin (hata bulmak) gücüdür
  • 16. 16© Vahid Garousi Test otomasyonunda Test-Kod Yaşam Döngüsü  Yazılım Test-Kod Mühendisliği (YTKM): Mühendislik ve sistematik yöntemleri kullanarak bu adımları en verimli şekilde yapmak Test aracı Test kodu geliştirilmesi Ürün kodu bakımı Otomatik test kodu geliştirme Test kodunun elle geliştirilmesi Yazılım Test Muhendisi Ürün kodu geliştirilme Test kodu eş- bakımı kullanıyor İzlenebilirlik bağlantılar Test Edilen Yazılım (TEY) Otomatik Test Küme Kalite değerlendirme İzlenebilirlik bağlantılar etkiliyoretkiliyor Kalite değerlendirme kullanılıyor Kalite iyileştirme Kalite iyileştirme
  • 17. 17© Vahid Garousi Test-Kodu Mühendisliğine Dünyada Verilen Önem
  • 18. 18© Vahid Garousi Sunum içeriği  Hacettepe Üniversitesinde Yazılım Test Mühendisliği dersi  Test-koduna genel bir bakış  Birkaç örnek  Test-kodunun kalitesi neden önemlidir?  Test-kodu yaşam döngüsü ve test-kod mühendisliği  Nasıl?  Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)  Test-kodunun kalitelisini doğrulayalım (Verifying test scripts)  TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co- maintaining test scripts with the SUT)  Ne öğreneceğiz?  Bu alanda, birkaç tekniği, araçları ve deneyimleri gözden geçireceğiz
  • 19. 19© Vahid Garousi Kaliteli Test-Kodu Nasıl Geliştirilir?  Manuel yöntem: test mühendisi el ile test kodu yazıyor  Normal kaynak kodu gibi, kaliteli kod yazmak lazım  Birçok önemli noktaya dikkat lazım  Test kodunun kalite yönleri ve ölçütleri nelerdir?  Test kodunun hem fonksiyonel (functional) ve hem fonksiyonel-dışı (non-functional) kalite yönleri vardır.  Fonksiyonel kalite: test kodunun ürün kodunu doğru ve sağlam test etmesidir.  Meşhur “Saatçiyi izlemek”(İngilizcede: “Watching the watchman”) sözü gibi, test kodu için de dikkatli doğrulama ve geçerleme lazım.  Test kodunun fonksiyonel-dışı kalitesi ise, “-bilirlik” ailesindeki kalite ölçütlerini kapsıyor, örneğin, bakıla-bilirlik (maintainability), anlaya-bilirlik (understandability) ve güvene-bilirlik (reliability).
  • 20. 20© Vahid Garousi Kaliteli Test-Kodu Nasıl Geliştirilir?  Çözüm: Test örüntüleri (Test patterns)  "Tasarım örüntülerine" (design patterns) benziyorlar  Örnek test örüntüleri:  Sayfa Nesneleri (Page objects): The Page Object pattern represents the screens of your web app as a series of objects  Web uygulamalarını otomatik test ederken, kullanıcı arayüzünde (UI) testler ile etkileşim alanları vardır.  Bir "Sayfa Nesnesi" test kodunun içinde tum sayfayı nesne olarak modelliyor.  Böylece, kopya kod miktarı azalıyor ve arayüz değişirse, düzeltme, test içinde değişikler yalnızca tek bir yerde gerekiyor.  Örnek: bir web-tabanlı email uygulamayı test ederken:  Yerine:  Daha çok örnek: https://code.google.com/p/selenium/wiki/PageObjects
  • 21. 21© Vahid Garousi Kaliteli Test-Kod: Test Örüntüler  Örnek test otomasyon aracı: Selenium  Çözüm: Test örüntüleri (Test patterns)  Ayrıntılar:
  • 22. 22© Vahid Garousi Kaliteli Test-Kodu: Birim testinde otomasyon  Test otomasyon altyapısı: JUnit (birim test için)  Örnek bir JUnit birim test kodu:  Android işletim sistemi kodundan: Acil numara (911) ayarının düzgün ayarlanmış olup olmadığını kontrol etmek
  • 23. 23© Vahid Garousi Kaliteli Test-Kodu: Test Örüntüleri  Test otomasyon altyapısı: JUnit  Birim testi için test örüntüleri, örnekler:  Test mantığımızı net bir şekilde yazmak için, testlerimizi nasıl bir yapıda oluşturmalıyız?  Öneri: testleri sırayla dört farklı adımda yapılandırmak  Dört-Adım Testi (Four-Phase Test)
  • 24. 24© Vahid Garousi Kaliteli Test-Kodu: Test Örüntüleri  Dört-Adım Testi (Four-Phase Test)  Faydalar:  Bakıla-bilirlik (maintainability)  Anlaya-bilirlik (understandability)  Modülerlik (modularity)
  • 25. 25© Vahid Garousi Kaliteli Test-Kodu: Test Örüntüleri  Birim testi için test örüntüleri  Ayrıntılar ve daha çok test örüntüsü:
  • 26. 26© Vahid Garousi Testleri Otomatik Üretmek  Manuel yöntem: test mühendisi el ile test kodu yazıyor  Otomatik yöntem: bir test otomasyon aracı kullanarak test kodu otomatik bir şekilde geliştirmek  Tekrar, farklı test seviyeleri için (birim ve sistem testi), farklı araçlar mevcut
  • 27. 27© Vahid Garousi Testleri Otomatik Üretmek  Bir projeden örnek  Firma:  .Net’de NUnit testlerini otomatik üretmek  Test Edilen Yazılım (TEY): Rocket adlı bir Veri Tabanlı Kontrol ve Gözetleme Sistemi (Supervisory Control and Data Acquisition (SCADA)  Sıkıntı: Manuel şekilde NUnit testleri geliştirmek çok zaman alıyordu, örneğin: denklik sınıflandırma (equivalence classing) metodun kullanarak, bu sistemde, 19,683 tane test senaryosu sadece bir birim (fonksiyon blok) için çıkıyordu. Kotu haber  (bu kadar test kodu yazmak çok efor istiyor)
  • 28. 28© Vahid Garousi Testleri Otomatik Üretmek  .Net’de NUnit testlerini otomatik üretmek İkili test Programın tüm ikili girdi kombinasyonlarını çalıştırmak için test senaryolarının tasarlandığı kara kutu test tasarım tekniği Ayrıca bakınız dikey dizi testi. A black box test design technique in which test cases are designed to execute all possible discrete combinations of each pair of input parameters. See also orthogonal array testing.
  • 29. 29© Vahid Garousi İkili Test (Pair-Wise Testing): Bir örnek  Deneysel çalışmalardan: “Hatalar genelde sadece birkaç değişken etkileşimi sebebiyle yaratılıyorlar, böylece sadece birkaç değişkenin etkileşimlerini kontrol eden testler hataları bulmakta çok etkin olmaktadır."  "Failures appear to be caused by interactions of only a few variables, so tests that cover all such few-variable interactions can be very effective.”  Örnek:  3 değişken  3 != 6 test senaryosu  Ama sadece bir test senaryo hatayı bulacaktır:  pressure<10  volume>300  Ve o senaryo, iyi değişkeninin etkileşimine aittir
  • 30. 30© Vahid Garousi İkili test: Deneysel çalışmalardan sonuçlar (Pair-Wise Testing): Results from Empirical Studies Değişkenlerin etkileşim sayısı Kümülatif yüzde
  • 31. 31© Vahid Garousi Testleri Otomatik Üretmek  .Net’de NUnit testleri otomatik üretmek
  • 32. 32© Vahid Garousi Sunum İçeriği  Test-koduna genel bir bakış  Birkaç örnek  Test-kodunun kalitesi neden önemlidir?  Test-kodu yaşam döngüsü ve test-kod mühendisliği (YTKM)  Nasıl?  Kaliteli test-kodu geliştirelim (Developing high-quality test scripts)  Test-kodu kalitelisini doğrulayalım (Verifying test scripts)  TEY (Test Edilen Yazılım) değiştikçe test-koduna bakım yapalım (Co-maintaining test scripts with the SUT)  Ne öğrendik?  Bu alanda, birkaç teknik, araçlar ve deneyimleri gözden geçireceğiz Bugün Sonra