mai putin stres. mai multa calitate.files.meetup.com/1531159/intro_automatizarea_testelor.pdfsyneto...
TRANSCRIPT
![Page 1: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/1.jpg)
Mai putin stres. Mai multa calitate.
![Page 2: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/2.jpg)
Syneto
Agile Coach
Product Owner
Developer din 2000 Interesat de agile din 2008 Membru al #agileworks Timisoara din 2009
![Page 3: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/3.jpg)
Nu mai avem timp sa il testam!Faceti release odata!!!!!
Trebuie sa il terminam pana saptamanaviitoare. Vino, te rog, si in weekend…
De doua zile ma chinui sa gasesc un bug si nu reusesc sa ii dau de cap
![Page 4: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/4.jpg)
http://agilemanifesto.org Principii
Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely.
Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.
![Page 5: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/5.jpg)
Cum putem sa:
Acceptam cerinte noi,
Mentinem ritmul…
… cand cantitatea de cod pe care trebuie sa o testam (manual) creste liniar cu numarul de functionalitati noi pe care le adaugam?
![Page 6: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/6.jpg)
Nu mentinem ritmul
Creste timpul de release
(Mai probabil) Testam mai putin
Scade calitatea
![Page 7: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/7.jpg)
Concepem si automatizam testele de verificare si validare a softului construit
Lasam calculatorulsa verificesi sa validezepentru noi
![Page 8: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/8.jpg)
Scop Refactoring Tipuri de teste Unelte Unit testing TDD Concluzii
![Page 9: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/9.jpg)
![Page 10: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/10.jpg)
Specificatii Inainte de dezvoltare
Documentatie Mereu actualizata
Plasa de siguranta Cand schimbam
Localizarea defectelor Cand apar bug-uri
Imbunatatirea calitatii Codul testabil este mai decuplat
Scaderea riscului Construim ce trebuie Nu stricam ce exista
![Page 11: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/11.jpg)
![Page 12: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/12.jpg)
To restructure software by applying a series of refactorings, without changing its observable behavior.
Martin Fowler
• Tehnica esentiala in agile• Schimbam designul codului existent• Nu adaugam de cod nou
![Page 13: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/13.jpg)
Scapam de “spaghetti code”
Schimbam design existent Facem codul mai usor de
inteles si mentinut Gasim bug-uri Programam mai usor ulterior
![Page 14: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/14.jpg)
void printOwing() {printBanner(); //print details System.out.println ("name: " + _name); System.out.println ("amount " + getOutstanding());
}
void printOwing() {printBanner();printDetails(getOutstanding());
}
void printDetails (double outstanding) { System.out.println ("name: " + _name); System.out.println ("amount " + outstanding);
}
![Page 15: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/15.jpg)
Exemplu de refactoring
Comments are code smells
Jason Gorman - Codemanship
http://www.youtube.com/watch?v=3cNR0PohDPM
![Page 16: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/16.jpg)
![Page 17: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/17.jpg)
![Page 18: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/18.jpg)
![Page 19: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/19.jpg)
SUnit jUnit DbUnit NUnit PHPUnit PyUnit Test::Unit
rSpec jBehave
![Page 20: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/20.jpg)
namespace bank {
using NUnit.Framework;
[TestFixture]
public class AccountTest {
[Test]
public void TransferFunds() {
Account source = new Account();
source.Deposit(200.00F);
Account destination = new Account();
destination.Deposit(150.00F);
source.TransferFunds(destination, 100.00F);
Assert.AreEqual(250.00F, destination.Balance);
Assert.AreEqual(100.00F, source.Balance);
}
} }
![Page 21: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/21.jpg)
public class SampleTest extends DBTestCase {
[…]
// Implements required setup methods here ...
public void testMe() throws Exception {
// Execute the tested code that modifies the database here ...
[…]
// Fetch database data after executing your code
IDataSet databaseDataSet = getConnection().createDataSet();
ITable actualTable = databaseDataSet.getTable("TABLE_NAME");
// Load expected data from an XML dataset
IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(
new File("expectedDataSet.xml"));
ITable expectedTable = expectedDataSet.getTable("TABLE_NAME");
// Assert actual database table match expected table
Assertion.assertEquals(expectedTable, actualTable);
} }
![Page 22: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/22.jpg)
require 'watir-webdriver'
b = Watir::Browser.new(:ie)b.goto 'http://www.openagile.ro'puts b.titleb.close
![Page 23: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/23.jpg)
Record Replay C#, Java, Perl, PHP,
Python, Ruby Fragil Nevoie de
refactoring
![Page 24: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/24.jpg)
|eg.Division||numerator|denominator|quotient?||10 |2 |5 ||12.6 |3 |4.2 ||100 |4 |33 |
![Page 25: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/25.jpg)
![Page 26: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/26.jpg)
SUnit 1997 – jUnit 2000 – mock objects Restul e istorie
![Page 27: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/27.jpg)
<?phprequire_once 'PHPUnit/Framework.php';
class ArrayTest extends PHPUnit_Framework_TestCase{
protected $fixture;
protected function setUp(){
// Create the Array fixture.$this->fixture = array();
}
public function testNewArrayIsEmpty(){
// Assert that the size of the Array fixture is 0.$this->assertEquals(0, sizeof($this->fixture));
}
public function testArrayContainsAnElement(){
// Add an element to the Array fixture.$this->fixture[] = 'Element';
// Assert that the size of the Array fixture is 1.$this->assertEquals(1, sizeof($this->fixture));
}}?>
• Teste• Setup/Teardown• Suite• Test runner• 4 faze
• Set up• Exercita• Verifica• Tear down
![Page 28: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/28.jpg)
Terminologie
SUT
DOC
Intre obiecte exista dependinte Altele nu pot fi folosite (sist. remote, ceas) Cum testam in mod individual?
Inlocuim DOC cu “dubluri”
Stubs, Mocks, Dummies, Spies, Fake objects
![Page 29: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/29.jpg)
require 'test/unit‘require 'mocha‘
class MiscExampleTest < Test::Unit::TestCase
def test_mocking_a_class_method
product = Product.new
Product.expects(:find).with(1).returns(product)
assert_equal product, Product.find(1)
end
def test_mocking_an_instance_method_on_a_real_object
product = Product.new
product.expects(:save).returns(true)
assert product.save
endend
![Page 30: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/30.jpg)
Trebuie mentinute Refactoring Design
Decuplare
Coeziune
Sunt mai dificil de adaugat pe cod existent
Working Effectively with Legacy Code
![Page 31: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/31.jpg)
![Page 32: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/32.jpg)
Metoda de dezvoltare in 3 pasi
Scrii un test care esueaza
Scrii codul care il face sa treaca
Refactor (cod + test) Pasi mici Variaza dimensiunea pasului
![Page 33: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/33.jpg)
Feedback rapid legat de deciziile de design Scapam de “analysis paralysis” Codul devine testabil Codul testabil e mai decuplat Codul decuplat e usor de intretinut
![Page 34: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/34.jpg)
Emergenta Doar cat e
necesar
![Page 35: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/35.jpg)
Does TDD scale to extremely large systems? What new tests would you have to write? What new kinds of refactorings would you need?
The largest, totally test-driven system I've been involved with is at LifeWare (www.lifeware.ch). After 4 years and 40 person/years, the system contains approximately 250,000 lines of functional code and 250,000 lines of test code in Smalltalk. There are 4,000 tests, executing in under 20 minutes. The full suite is run several times each day. The amount of functionality in the system seems to have no bearing on the effectiveness of TDD. By eliminating duplication, you tend to create more smaller objects, and those objects can be tested in isolation independent of the size of the application.
Kent Beck, TDD: By Example
![Page 36: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/36.jpg)
Programarea e dificila Limbaj Mediu (OS, editor, librarii) OOD Patterns Testare
Avem nevoie de “mesteri” (craftsmen) Invata continuu Exerseaza (craftsmanship movement) Code retreats, pair programming, dojos
![Page 37: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/37.jpg)
Interfata in Java pentru Tokyo Tyrant
Kent Beck (autor prima carte TDD)
http://www.vimeo.com/10789674 http://www.vimeo.com/10927341
![Page 38: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/38.jpg)
![Page 39: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/39.jpg)
Automatizeaza-ti testele pentru a crestecalitatea codului si a o mentine.
Foloseste refactoring des pentruimbunatarirea designului.
Foloseste TDD pentru a-ti “conduce” designul.
Testele nu inlocuiesc codul de calitate. Alege un proiect nou la care sa aplici aceste
practici. Nu trebuie sa fie unul de la lucru.
![Page 40: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/40.jpg)
www.xunitpatterns.com googletesting.blogspot.com www.martinfowler.com www.exampler.com www.youtube.com/user/parlezuml dannorth.net www.infoq.com lisacrispin.com
![Page 41: Mai putin stres. Mai multa calitate.files.meetup.com/1531159/Intro_automatizarea_testelor.pdfSyneto Agile Coach Product Owner Developer din 2000 Interesat de agile din 2008 Membru](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028c2bf2e19760608370eb7/html5/thumbnails/41.jpg)
Test-Driven Development: by Example (Kent Beck) Refactoring (Martin Fowler) xUnit Test Patterns (Gerrard Meszaros) Growing OO software guided by tests (Steve
Freeman, Nat Pryce) Agile Testing (Lisa Crispin, Janet Gregory)