SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
Developer Testing
Achieving a hundred percent test coverage for database and Swing applications




                                                                Stephan J. Schmidt


                                                                cintoo lead developer
                                                                http://cintoo.org
                                                                stephan@cintoo.org
2




           Contents



                  • What is developer testing

                  • Why you should practice developer testing

                  • How you can do developer testing

                  • How to test nasty things




Stephan J. Schmidt, cintoo
3




           What is Developer Testing




   Simple:

           Testing done by developers




Stephan J. Schmidt, cintoo
4




           Acceptance versus Developer Tests


                              Acceptence       Developer
                                Testing         Testing




               Tests:        System against
                             Requirements
                                              Code against
                                                Design




Stephan J. Schmidt, cintoo
5




           Why?



                  • Improves the health of your system

                  • Gives you a good feeling

                  • Makes you more confident

                  • Developer testing makes you more effective




Stephan J. Schmidt, cintoo
6




           Accountability


                  • Developer testing leads to accountability

                  • Developers should be accountable for their code

                  • Business people often think they are

                  • Offshoring/ Outsourcing might be due to lack of
                    accountability

                  • Accountability needed for CMM5




Stephan J. Schmidt, cintoo
7




           Save time


                  • Less gold plating

                  • Developers know when to stop

                  • Less thinking what to do next

                  • Tests result in cleaner, more atomic design which
                    reduces time when introducing new features

                  • Regression testing finds new bugs fast




Stephan J. Schmidt, cintoo
8




           Implementing Developer Testing

                  • Be pragmatic!

                  • It’s free

                  • Frameworks like TestNG or xUnit (JUnit, NUnit...)

                  • TestCases with methods (tests) which test your classes

                  • Run tests automatically and frequently

                  • Use automatic builds (Pulse, Cruise control, ..)

                  • Set goals (metric based)




Stephan J. Schmidt, cintoo
9




           Example adding two numbers




                             public class Math {
                               public static int add(int a, int b) {
                                 return a + b;
                               }
                             }




Stephan J. Schmidt, cintoo
10




           Testing Math with an Unit Test

             public class TestMath {

                   @Test
                   public void addTwoPositiveNumbers() {
                    Asserts.assertEquals(
                      "2 + 3 = 5", 5, Math.add(2,3));
                    }

                   @Test
                   public void addZero() {
                    Asserts.assertEquals(
                      "1 + 0 = 1", 1, Math.add(1,0));
                    Asserts.assertEquals(
                      "0 + 1 = 1", 1, Math.add(0,1));
                    }
             }




Stephan J. Schmidt, cintoo
11




           Test tools

            • Tests are run with
              a testing tool

            • Tool displays non-
              working tests




Stephan J. Schmidt, cintoo
12




           Build Server
                  • Runs tests automatically on check-in or time based

                  • Prevents non working tests in repository after check-ins

                       (though they might run locally)




Stephan J. Schmidt, cintoo
13




           Example application SuperAdd



                  • Will replace Excel!

                  • Adding two numbers

                  • Graphical user interface for data entry

                  • Storing the calculations in a database




Stephan J. Schmidt, cintoo
14




           Architecture


                     • Three tier application    GUI


                     • Different testing
                       scenarios for every       Logic

                       tier
                                                Storage




Stephan J. Schmidt, cintoo
15




           Architecture
                                                                  Buttons



                                 Application Border           SwingCalcView
                                       State
                                                                 CalcView
                                                                              GUI             2
                                                                CalcEditor




                             1         Logic                       Math         CalcManager




                                                      3
                                                                                CalcStorage
                                                               Storage
                                                                              JDBCCalcStorage


                                                  Application Border State


                                                                                    DB




Stephan J. Schmidt, cintoo
16




           Testing SuperAdd




                  • Test Logic (Math, CalcManager) easy

                  • Test Storage (JDBCCalcStorage) not so easy

                  • Test GUI (CalcView, CalcEditor) hmm. some thinking needed




Stephan J. Schmidt, cintoo
17




           Testing Math is easy                                1

                                         calculate / ok


                                Test                  Math




                  • Already shown, lucky me :-)

                  • Test for negative numbers, overflow, ...




Stephan J. Schmidt, cintoo
18




           Testing CalcManager                                               1
                                          set / ok
                                                      CalcManager

                                   Test
                                           ok        MockCalcStorage




                  • CalcManager logs correct calculations to the storage

                  • Problem is the usage of a database

                  • Testing not in isolation

                  • Solution is usage of Mock objects for database storage




Stephan J. Schmidt, cintoo
19




           Mock objects


                                                       Test


                  • In-replacement for objects

                  • Mocks simulate the
                    dependencies                   Class to Test


                  • Testing in isolation

                  • Testing classes "from below"   Dependencies
                                                     as Mocks




Stephan J. Schmidt, cintoo
20




           GUI Testing       2




Stephan J. Schmidt, cintoo
21




           Usually Java GUIs look like this
             public class View {
                 ...
                 calculateButton.addActionListener(
                   ...
                     sumField.setText(
                       Math.add(
                         aField.getText(),
                         bField.getText());
                 ));
               }
                                     Hard to test, depends on
             }
                                        Swing. Logic not reusable
                                        in different GUI frameworks!



Stephan J. Schmidt, cintoo
22




           GUI splitting

                  • View/Editor pattern, split GUI in view and editor

                  • Remove ALL logic from the view

                  • Editor contains the logic



                                         View


                             GUI

                                                          Editor




Stephan J. Schmidt, cintoo
23




           View
                public class View {
                    ...
                    calculateButton.addActionListener(
                      ...
                      editor.calculate()
                    ));
                  }
                  public void setSum(int sum) {
                    sumField.setText(sum);
                  }
                }




Stephan J. Schmidt, cintoo
24




           Editor


                public class Editor {
                  public void calculate() {
                    int a = view.getAValue();
                    int b = view.getBValue();
                    view.setSum(Math.add(a,b));
                  }
                }
                                      Logic




Stephan J. Schmidt, cintoo
25




           Editor Test

                  @Test
                  public void calculate() {
                    Mock mockCalcView = mock(CalcView.class);
                    mockCalcView.expects(once())
                      .method("getAValue").will(returnValue(2));
                    ...
                    Mock mockCalcManager = mock(CalcManager.class);
                    mockCalcManager.expects(once())
                      .method("logCalc").with(eq(2), eq(3), eq(5));

                       CalcEditor editor = new CalcEditor(
                         (CalcView) mockCalcView.proxy(),
                         (CalcManager) mockCalcManager.proxy());
                       editor.calculate();
                  }




Stephan J. Schmidt, cintoo
26




           GUI Testing                                                       2

                  • Record/ Playback: Actions are recorded and after
                    that a tester replays the recorded actions

                  • Click tests: Testers click buttons in a GUI according to a
                    test plan

                  • Programmatic: Developer writes GUI tests with
                    framework

                  • Record is simple, but breaks easily with GUI changes

                  • Click tests are simple, but annoying. A lot of
                    documentation changes are needed after GUI
                    changes

                  • Programmatic approach needs developers to define
                    tests, but is much more robust against changes

Stephan J. Schmidt, cintoo
27




           Testing with Jemmy

                                                     Jemmy
                                          click /
                                            ok
                                   Test             SwingView


                                            ok
                                                    MockEditor




                  • Jemmy is a windows driver

                  • Provides operators like JButtonOperator

                  • Test: Find component then drive component through
                    operator then check for result/ state



Stephan J. Schmidt, cintoo
28




           Testing the Swing view

                             Mock mockEditor = mock(CalcEditor.class);
                             mockEditor.expects(once()).method("calculate");
        Find                 ...
                             JTextFieldOperator aField =
   component                   new JTextFieldOperator(main, name("a"));
                             ...
                             JButtonOperator calculateButton =
                               new JButtonOperator(main);

                             aField.enterText("2");
        Drive                bField.enterText("3");
   component
                             calculateButton.doClick();

                             assertEquals(sumField.getText(), 5);

           Check
           results

Stephan J. Schmidt, cintoo
29




           Database layer                                                        3
                  • Store all calculations

                  • Relational database management system


                                 Calculations                 Calculations
                                                  add()
                             a        b     sum           a        b     sum

                                                          2        3         5




Stephan J. Schmidt, cintoo
30




           Testing the database layer

                                      set / ok
                                                 JDBCCalcStorage

                               Test


                                         ok            In
                                                     Memory




                 • Use in-memory database

                 • Free utilities exist to check results in database




Stephan J. Schmidt, cintoo
31




           Writing and checking data
                  CalcStorage storage = new JdbcCalcStorage(config);

                  storage.store(2, 3, 5);

                  assertEquals( "One row has been added",
                     1,
                     rowCount("Calculations"));

                  assertEquals("Correct data has been written",
                     1,
                     rowCount("Calculations", "a=2 AND b=3 AND sum=5"));



                  • write data to database then check data in database

                  • use helper methods like rowCount




Stephan J. Schmidt, cintoo
32




       In-Memory Database configuration with HSQL

                   Config config = new Config(
                      "sa",
                      "",
                      "jdbc:hsqldb:mem:testdb",
                      "org.hsqldb.jdbcDriver");



                  • HSQL in memory database,

                       automatically knows “sa” user

                  • automatically creates database

                  • hsql.jar with driver, all inclusive

                  • Create and drop tables in setUp and tearDown


Stephan J. Schmidt, cintoo
33




           Also test O/R Mappers


                  • Even with Hibernate, ... use unit tests

                  • Are you sure your configuration does cascading
                    delete correctly?

                  • Do the queries return the correct objects?

                  • Are all those foreign key relationships managed?

                  • For big project probably only test important key parts




Stephan J. Schmidt, cintoo
34




    Coverage
         • Code is
           instrumented by
           coverage tool

         • Find code which
           is not executed
           during tests

         • Statements,
           methods,
           conditionals

         • Help QA to
           understand your
           tests




Stephan J. Schmidt, cintoo
35




           100% Test Coverage




                  • Not faked :-)

                  • Filter main and Exceptions away (not your own!)

                  • Possible but usually not needed

                  • May distract developers from real goals


Stephan J. Schmidt, cintoo
36




           Credits


                  • Thanks to Zutubi for Pulse integration server

                  • Thanks to cenqua for Clover code coverage

                  • Thanks to Cedric for TestNG, Kent and Martin for JUnit

                  • Thanks to the creators of the other tools

                  • Tools used: IDEA, jMock, Pulse, Clover, Jemmy, TestNG/
                    JUnit, HSQL




Stephan J. Schmidt, cintoo
37




           References



                  • Kent Beck, “The Future of Developer Testing”, SDForum
                    2004

                  • David Astels, “test-driven development - A Practical
                    Guide”, 2003

                  • Steve Freeman, Nat Pryce, Tim Mackinnon, Joe
                    Walnes, “Mock Roles, not Objects”




Stephan J. Schmidt, cintoo
Stephan J. Schmidt

cintoo lead developer
http://cintoo.org
stephan@cintoo.org

Weitere ähnliche Inhalte

Was ist angesagt?

Informatica basics for beginners | Informatica ppt
Informatica basics for beginners | Informatica pptInformatica basics for beginners | Informatica ppt
Informatica basics for beginners | Informatica pptIQ Online Training
 
Challenges in Building a Data Pipeline
Challenges in Building a Data PipelineChallenges in Building a Data Pipeline
Challenges in Building a Data PipelineManish Kumar
 
Ozone: An Object Store in HDFS
Ozone: An Object Store in HDFSOzone: An Object Store in HDFS
Ozone: An Object Store in HDFSDataWorks Summit
 
Enterprise API New Features and Roadmap
Enterprise API New Features and RoadmapEnterprise API New Features and Roadmap
Enterprise API New Features and RoadmapSalesforce Developers
 
Real-Time Streaming: Intro to Amazon Kinesis
Real-Time Streaming: Intro to Amazon KinesisReal-Time Streaming: Intro to Amazon Kinesis
Real-Time Streaming: Intro to Amazon KinesisAmazon Web Services
 
Informatica Power Center 7.1
Informatica Power Center 7.1Informatica Power Center 7.1
Informatica Power Center 7.1ganblues
 
Implementando un Data Mart con SQL Server 2016
Implementando un Data Mart con SQL Server 2016Implementando un Data Mart con SQL Server 2016
Implementando un Data Mart con SQL Server 2016Raul Martin Sarachaga Diaz
 
Data Warehouse Project Report
Data Warehouse Project Report Data Warehouse Project Report
Data Warehouse Project Report Tom Donoghue
 
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...BI Brainz
 
QuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionQuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionRTTS
 
Finit solutions - Automating Data Loads with FDMEE
Finit solutions - Automating Data Loads with FDMEEFinit solutions - Automating Data Loads with FDMEE
Finit solutions - Automating Data Loads with FDMEEfinitsolutions
 
Introduction to Power BI a Business Intelligence Tool by Apurva Ramteke
Introduction to Power BI a Business Intelligence Tool by Apurva RamtekeIntroduction to Power BI a Business Intelligence Tool by Apurva Ramteke
Introduction to Power BI a Business Intelligence Tool by Apurva RamtekeApurva Ramteke
 
Informatica Powercenter Architecture
Informatica Powercenter ArchitectureInformatica Powercenter Architecture
Informatica Powercenter ArchitectureBigClasses Com
 
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...Edureka!
 
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)(Joe), Sanghun Kim
 
Managing 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with AmbariManaging 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with AmbariDataWorks Summit
 
Building a modern data warehouse
Building a modern data warehouseBuilding a modern data warehouse
Building a modern data warehouseJames Serra
 
Informatica Transformations with Examples | Informatica Tutorial | Informatic...
Informatica Transformations with Examples | Informatica Tutorial | Informatic...Informatica Transformations with Examples | Informatica Tutorial | Informatic...
Informatica Transformations with Examples | Informatica Tutorial | Informatic...Edureka!
 
Power BI new workspace experience in power bi
Power BI  new workspace experience in power biPower BI  new workspace experience in power bi
Power BI new workspace experience in power biAmit Kumar ☁
 

Was ist angesagt? (20)

Informatica basics for beginners | Informatica ppt
Informatica basics for beginners | Informatica pptInformatica basics for beginners | Informatica ppt
Informatica basics for beginners | Informatica ppt
 
Challenges in Building a Data Pipeline
Challenges in Building a Data PipelineChallenges in Building a Data Pipeline
Challenges in Building a Data Pipeline
 
Ozone: An Object Store in HDFS
Ozone: An Object Store in HDFSOzone: An Object Store in HDFS
Ozone: An Object Store in HDFS
 
Enterprise API New Features and Roadmap
Enterprise API New Features and RoadmapEnterprise API New Features and Roadmap
Enterprise API New Features and Roadmap
 
Real-Time Streaming: Intro to Amazon Kinesis
Real-Time Streaming: Intro to Amazon KinesisReal-Time Streaming: Intro to Amazon Kinesis
Real-Time Streaming: Intro to Amazon Kinesis
 
Informatica Power Center 7.1
Informatica Power Center 7.1Informatica Power Center 7.1
Informatica Power Center 7.1
 
Implementando un Data Mart con SQL Server 2016
Implementando un Data Mart con SQL Server 2016Implementando un Data Mart con SQL Server 2016
Implementando un Data Mart con SQL Server 2016
 
Data Warehouse Project Report
Data Warehouse Project Report Data Warehouse Project Report
Data Warehouse Project Report
 
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...
Analysing and Troubleshooting Performance Issues in SAP BusinessObjects BI Re...
 
QuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionQuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solution
 
Finit solutions - Automating Data Loads with FDMEE
Finit solutions - Automating Data Loads with FDMEEFinit solutions - Automating Data Loads with FDMEE
Finit solutions - Automating Data Loads with FDMEE
 
Introduction to Power BI a Business Intelligence Tool by Apurva Ramteke
Introduction to Power BI a Business Intelligence Tool by Apurva RamtekeIntroduction to Power BI a Business Intelligence Tool by Apurva Ramteke
Introduction to Power BI a Business Intelligence Tool by Apurva Ramteke
 
Informatica Powercenter Architecture
Informatica Powercenter ArchitectureInformatica Powercenter Architecture
Informatica Powercenter Architecture
 
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...
Power BI Training | Getting Started with Power BI | Power BI Tutorial | Power...
 
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)
[IBM 김상훈] 오브젝트스토리지 | 늘어만 가는 데이터 저장문제로 골 아프신가요? (자료를 다운로드하시면 고화질로 보실 수 있습니다.)
 
Managing 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with AmbariManaging 2000 Node Cluster with Ambari
Managing 2000 Node Cluster with Ambari
 
Building a modern data warehouse
Building a modern data warehouseBuilding a modern data warehouse
Building a modern data warehouse
 
What is ETL?
What is ETL?What is ETL?
What is ETL?
 
Informatica Transformations with Examples | Informatica Tutorial | Informatic...
Informatica Transformations with Examples | Informatica Tutorial | Informatic...Informatica Transformations with Examples | Informatica Tutorial | Informatic...
Informatica Transformations with Examples | Informatica Tutorial | Informatic...
 
Power BI new workspace experience in power bi
Power BI  new workspace experience in power biPower BI  new workspace experience in power bi
Power BI new workspace experience in power bi
 

Ähnlich wie Developer Testing

PyCon 9: Continuous Delivery starts at your Development Dnvironment
PyCon 9: Continuous Delivery starts at your Development DnvironmentPyCon 9: Continuous Delivery starts at your Development Dnvironment
PyCon 9: Continuous Delivery starts at your Development DnvironmentPeter Bittner
 
Agile Development in Aerospace and Defense
Agile Development in Aerospace and DefenseAgile Development in Aerospace and Defense
Agile Development in Aerospace and DefenseJim Nickel
 
Fix-Price Projects And Agile – PyCon Sette
Fix-Price Projects And Agile – PyCon SetteFix-Price Projects And Agile – PyCon Sette
Fix-Price Projects And Agile – PyCon SettePeter Bittner
 
Keynote AST 2016
Keynote AST 2016Keynote AST 2016
Keynote AST 2016Kim Herzig
 
Test driven development
Test driven developmentTest driven development
Test driven developmentShalabh Saxena
 
Guidelines to Measuring Test Automation ROI
 Guidelines to Measuring Test Automation ROI Guidelines to Measuring Test Automation ROI
Guidelines to Measuring Test Automation ROIPerfecto by Perforce
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptxskknowledge
 
Machine programming
Machine programmingMachine programming
Machine programmingDESMOND YUEN
 
Tuning for Systematic Trading: Talk 2: Deep Learning
Tuning for Systematic Trading: Talk 2: Deep LearningTuning for Systematic Trading: Talk 2: Deep Learning
Tuning for Systematic Trading: Talk 2: Deep LearningSigOpt
 
Technical meeting automated testing with vs2010
Technical meeting automated testing with vs2010Technical meeting automated testing with vs2010
Technical meeting automated testing with vs2010Clemens Reijnen
 
An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)Julien SIMON
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...TEST Huddle
 
Fri benghiat gil-odsc-data-kitchen-data science to dataops
Fri benghiat gil-odsc-data-kitchen-data science to dataopsFri benghiat gil-odsc-data-kitchen-data science to dataops
Fri benghiat gil-odsc-data-kitchen-data science to dataopsDataKitchen
 
ODSC data science to DataOps
ODSC data science to DataOpsODSC data science to DataOps
ODSC data science to DataOpsChristopher Bergh
 
Zero-bug Software, Mathematically Guaranteed
Zero-bug Software, Mathematically GuaranteedZero-bug Software, Mathematically Guaranteed
Zero-bug Software, Mathematically GuaranteedAshley Zupkus
 
4 florin coada - dast automation, more value for less work
4   florin coada - dast automation, more value for less work4   florin coada - dast automation, more value for less work
4 florin coada - dast automation, more value for less workIevgenii Katsan
 
OOSE Unit 5 PPT.ppt
OOSE Unit 5 PPT.pptOOSE Unit 5 PPT.ppt
OOSE Unit 5 PPT.pptitadmin33
 
Product quality in agile project
Product quality in agile projectProduct quality in agile project
Product quality in agile projectNhan Nguyen
 

Ähnlich wie Developer Testing (20)

PyCon 9: Continuous Delivery starts at your Development Dnvironment
PyCon 9: Continuous Delivery starts at your Development DnvironmentPyCon 9: Continuous Delivery starts at your Development Dnvironment
PyCon 9: Continuous Delivery starts at your Development Dnvironment
 
Agile Development in Aerospace and Defense
Agile Development in Aerospace and DefenseAgile Development in Aerospace and Defense
Agile Development in Aerospace and Defense
 
Fix-Price Projects And Agile – PyCon Sette
Fix-Price Projects And Agile – PyCon SetteFix-Price Projects And Agile – PyCon Sette
Fix-Price Projects And Agile – PyCon Sette
 
Keynote AST 2016
Keynote AST 2016Keynote AST 2016
Keynote AST 2016
 
ES3-2020-05 Testing
ES3-2020-05 TestingES3-2020-05 Testing
ES3-2020-05 Testing
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Guidelines to Measuring Test Automation ROI
 Guidelines to Measuring Test Automation ROI Guidelines to Measuring Test Automation ROI
Guidelines to Measuring Test Automation ROI
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptx
 
Machine programming
Machine programmingMachine programming
Machine programming
 
Tuning for Systematic Trading: Talk 2: Deep Learning
Tuning for Systematic Trading: Talk 2: Deep LearningTuning for Systematic Trading: Talk 2: Deep Learning
Tuning for Systematic Trading: Talk 2: Deep Learning
 
Technical meeting automated testing with vs2010
Technical meeting automated testing with vs2010Technical meeting automated testing with vs2010
Technical meeting automated testing with vs2010
 
An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
 
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAUTest Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
 
Fri benghiat gil-odsc-data-kitchen-data science to dataops
Fri benghiat gil-odsc-data-kitchen-data science to dataopsFri benghiat gil-odsc-data-kitchen-data science to dataops
Fri benghiat gil-odsc-data-kitchen-data science to dataops
 
ODSC data science to DataOps
ODSC data science to DataOpsODSC data science to DataOps
ODSC data science to DataOps
 
Zero-bug Software, Mathematically Guaranteed
Zero-bug Software, Mathematically GuaranteedZero-bug Software, Mathematically Guaranteed
Zero-bug Software, Mathematically Guaranteed
 
4 florin coada - dast automation, more value for less work
4   florin coada - dast automation, more value for less work4   florin coada - dast automation, more value for less work
4 florin coada - dast automation, more value for less work
 
OOSE Unit 5 PPT.ppt
OOSE Unit 5 PPT.pptOOSE Unit 5 PPT.ppt
OOSE Unit 5 PPT.ppt
 
Product quality in agile project
Product quality in agile projectProduct quality in agile project
Product quality in agile project
 

Mehr von Stephan Schmidt

Focus, Focus, Focus - The one thing that makes a difference
Focus, Focus, Focus - The one thing that makes a differenceFocus, Focus, Focus - The one thing that makes a difference
Focus, Focus, Focus - The one thing that makes a differenceStephan Schmidt
 
Employee Live Cycle JAX 2016
Employee Live Cycle JAX 2016Employee Live Cycle JAX 2016
Employee Live Cycle JAX 2016Stephan Schmidt
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with ReduxStephan Schmidt
 
Short Guide to Productivity
Short Guide to ProductivityShort Guide to Productivity
Short Guide to ProductivityStephan Schmidt
 
10 Years of My Scrum Experience
10 Years of My Scrum Experience10 Years of My Scrum Experience
10 Years of My Scrum ExperienceStephan Schmidt
 
What Top Management Needs to Know About IT
What Top Management Needs to Know About ITWhat Top Management Needs to Know About IT
What Top Management Needs to Know About ITStephan Schmidt
 
What managers need_to_know
What managers need_to_knowWhat managers need_to_know
What managers need_to_knowStephan Schmidt
 
What everyone should know about time to market
What everyone should know about time to marketWhat everyone should know about time to market
What everyone should know about time to marketStephan Schmidt
 
Better Strategies for Null Handling in Java
Better Strategies for Null Handling in JavaBetter Strategies for Null Handling in Java
Better Strategies for Null Handling in JavaStephan Schmidt
 
Berlin.JAR: Web future without web frameworks
Berlin.JAR: Web future without web frameworksBerlin.JAR: Web future without web frameworks
Berlin.JAR: Web future without web frameworksStephan Schmidt
 

Mehr von Stephan Schmidt (11)

Focus, Focus, Focus - The one thing that makes a difference
Focus, Focus, Focus - The one thing that makes a differenceFocus, Focus, Focus - The one thing that makes a difference
Focus, Focus, Focus - The one thing that makes a difference
 
Employee Live Cycle JAX 2016
Employee Live Cycle JAX 2016Employee Live Cycle JAX 2016
Employee Live Cycle JAX 2016
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
Short Guide to Productivity
Short Guide to ProductivityShort Guide to Productivity
Short Guide to Productivity
 
10 Years of My Scrum Experience
10 Years of My Scrum Experience10 Years of My Scrum Experience
10 Years of My Scrum Experience
 
What Top Management Needs to Know About IT
What Top Management Needs to Know About ITWhat Top Management Needs to Know About IT
What Top Management Needs to Know About IT
 
What managers need_to_know
What managers need_to_knowWhat managers need_to_know
What managers need_to_know
 
What everyone should know about time to market
What everyone should know about time to marketWhat everyone should know about time to market
What everyone should know about time to market
 
LMAX Architecture
LMAX ArchitectureLMAX Architecture
LMAX Architecture
 
Better Strategies for Null Handling in Java
Better Strategies for Null Handling in JavaBetter Strategies for Null Handling in Java
Better Strategies for Null Handling in Java
 
Berlin.JAR: Web future without web frameworks
Berlin.JAR: Web future without web frameworksBerlin.JAR: Web future without web frameworks
Berlin.JAR: Web future without web frameworks
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Developer Testing

  • 1. Developer Testing Achieving a hundred percent test coverage for database and Swing applications Stephan J. Schmidt cintoo lead developer http://cintoo.org stephan@cintoo.org
  • 2. 2 Contents • What is developer testing • Why you should practice developer testing • How you can do developer testing • How to test nasty things Stephan J. Schmidt, cintoo
  • 3. 3 What is Developer Testing Simple: Testing done by developers Stephan J. Schmidt, cintoo
  • 4. 4 Acceptance versus Developer Tests Acceptence Developer Testing Testing Tests: System against Requirements Code against Design Stephan J. Schmidt, cintoo
  • 5. 5 Why? • Improves the health of your system • Gives you a good feeling • Makes you more confident • Developer testing makes you more effective Stephan J. Schmidt, cintoo
  • 6. 6 Accountability • Developer testing leads to accountability • Developers should be accountable for their code • Business people often think they are • Offshoring/ Outsourcing might be due to lack of accountability • Accountability needed for CMM5 Stephan J. Schmidt, cintoo
  • 7. 7 Save time • Less gold plating • Developers know when to stop • Less thinking what to do next • Tests result in cleaner, more atomic design which reduces time when introducing new features • Regression testing finds new bugs fast Stephan J. Schmidt, cintoo
  • 8. 8 Implementing Developer Testing • Be pragmatic! • It’s free • Frameworks like TestNG or xUnit (JUnit, NUnit...) • TestCases with methods (tests) which test your classes • Run tests automatically and frequently • Use automatic builds (Pulse, Cruise control, ..) • Set goals (metric based) Stephan J. Schmidt, cintoo
  • 9. 9 Example adding two numbers public class Math { public static int add(int a, int b) { return a + b; } } Stephan J. Schmidt, cintoo
  • 10. 10 Testing Math with an Unit Test public class TestMath { @Test public void addTwoPositiveNumbers() { Asserts.assertEquals( "2 + 3 = 5", 5, Math.add(2,3)); } @Test public void addZero() { Asserts.assertEquals( "1 + 0 = 1", 1, Math.add(1,0)); Asserts.assertEquals( "0 + 1 = 1", 1, Math.add(0,1)); } } Stephan J. Schmidt, cintoo
  • 11. 11 Test tools • Tests are run with a testing tool • Tool displays non- working tests Stephan J. Schmidt, cintoo
  • 12. 12 Build Server • Runs tests automatically on check-in or time based • Prevents non working tests in repository after check-ins (though they might run locally) Stephan J. Schmidt, cintoo
  • 13. 13 Example application SuperAdd • Will replace Excel! • Adding two numbers • Graphical user interface for data entry • Storing the calculations in a database Stephan J. Schmidt, cintoo
  • 14. 14 Architecture • Three tier application GUI • Different testing scenarios for every Logic tier Storage Stephan J. Schmidt, cintoo
  • 15. 15 Architecture Buttons Application Border SwingCalcView State CalcView GUI 2 CalcEditor 1 Logic Math CalcManager 3 CalcStorage Storage JDBCCalcStorage Application Border State DB Stephan J. Schmidt, cintoo
  • 16. 16 Testing SuperAdd • Test Logic (Math, CalcManager) easy • Test Storage (JDBCCalcStorage) not so easy • Test GUI (CalcView, CalcEditor) hmm. some thinking needed Stephan J. Schmidt, cintoo
  • 17. 17 Testing Math is easy 1 calculate / ok Test Math • Already shown, lucky me :-) • Test for negative numbers, overflow, ... Stephan J. Schmidt, cintoo
  • 18. 18 Testing CalcManager 1 set / ok CalcManager Test ok MockCalcStorage • CalcManager logs correct calculations to the storage • Problem is the usage of a database • Testing not in isolation • Solution is usage of Mock objects for database storage Stephan J. Schmidt, cintoo
  • 19. 19 Mock objects Test • In-replacement for objects • Mocks simulate the dependencies Class to Test • Testing in isolation • Testing classes "from below" Dependencies as Mocks Stephan J. Schmidt, cintoo
  • 20. 20 GUI Testing 2 Stephan J. Schmidt, cintoo
  • 21. 21 Usually Java GUIs look like this public class View { ... calculateButton.addActionListener( ... sumField.setText( Math.add( aField.getText(), bField.getText()); )); } Hard to test, depends on } Swing. Logic not reusable in different GUI frameworks! Stephan J. Schmidt, cintoo
  • 22. 22 GUI splitting • View/Editor pattern, split GUI in view and editor • Remove ALL logic from the view • Editor contains the logic View GUI Editor Stephan J. Schmidt, cintoo
  • 23. 23 View public class View { ... calculateButton.addActionListener( ... editor.calculate() )); } public void setSum(int sum) { sumField.setText(sum); } } Stephan J. Schmidt, cintoo
  • 24. 24 Editor public class Editor { public void calculate() { int a = view.getAValue(); int b = view.getBValue(); view.setSum(Math.add(a,b)); } } Logic Stephan J. Schmidt, cintoo
  • 25. 25 Editor Test @Test public void calculate() { Mock mockCalcView = mock(CalcView.class); mockCalcView.expects(once()) .method("getAValue").will(returnValue(2)); ... Mock mockCalcManager = mock(CalcManager.class); mockCalcManager.expects(once()) .method("logCalc").with(eq(2), eq(3), eq(5)); CalcEditor editor = new CalcEditor( (CalcView) mockCalcView.proxy(), (CalcManager) mockCalcManager.proxy()); editor.calculate(); } Stephan J. Schmidt, cintoo
  • 26. 26 GUI Testing 2 • Record/ Playback: Actions are recorded and after that a tester replays the recorded actions • Click tests: Testers click buttons in a GUI according to a test plan • Programmatic: Developer writes GUI tests with framework • Record is simple, but breaks easily with GUI changes • Click tests are simple, but annoying. A lot of documentation changes are needed after GUI changes • Programmatic approach needs developers to define tests, but is much more robust against changes Stephan J. Schmidt, cintoo
  • 27. 27 Testing with Jemmy Jemmy click / ok Test SwingView ok MockEditor • Jemmy is a windows driver • Provides operators like JButtonOperator • Test: Find component then drive component through operator then check for result/ state Stephan J. Schmidt, cintoo
  • 28. 28 Testing the Swing view Mock mockEditor = mock(CalcEditor.class); mockEditor.expects(once()).method("calculate"); Find ... JTextFieldOperator aField = component new JTextFieldOperator(main, name("a")); ... JButtonOperator calculateButton = new JButtonOperator(main); aField.enterText("2"); Drive bField.enterText("3"); component calculateButton.doClick(); assertEquals(sumField.getText(), 5); Check results Stephan J. Schmidt, cintoo
  • 29. 29 Database layer 3 • Store all calculations • Relational database management system Calculations Calculations add() a b sum a b sum 2 3 5 Stephan J. Schmidt, cintoo
  • 30. 30 Testing the database layer set / ok JDBCCalcStorage Test ok In Memory • Use in-memory database • Free utilities exist to check results in database Stephan J. Schmidt, cintoo
  • 31. 31 Writing and checking data CalcStorage storage = new JdbcCalcStorage(config); storage.store(2, 3, 5); assertEquals( "One row has been added", 1, rowCount("Calculations")); assertEquals("Correct data has been written", 1, rowCount("Calculations", "a=2 AND b=3 AND sum=5")); • write data to database then check data in database • use helper methods like rowCount Stephan J. Schmidt, cintoo
  • 32. 32 In-Memory Database configuration with HSQL Config config = new Config( "sa", "", "jdbc:hsqldb:mem:testdb", "org.hsqldb.jdbcDriver"); • HSQL in memory database, automatically knows “sa” user • automatically creates database • hsql.jar with driver, all inclusive • Create and drop tables in setUp and tearDown Stephan J. Schmidt, cintoo
  • 33. 33 Also test O/R Mappers • Even with Hibernate, ... use unit tests • Are you sure your configuration does cascading delete correctly? • Do the queries return the correct objects? • Are all those foreign key relationships managed? • For big project probably only test important key parts Stephan J. Schmidt, cintoo
  • 34. 34 Coverage • Code is instrumented by coverage tool • Find code which is not executed during tests • Statements, methods, conditionals • Help QA to understand your tests Stephan J. Schmidt, cintoo
  • 35. 35 100% Test Coverage • Not faked :-) • Filter main and Exceptions away (not your own!) • Possible but usually not needed • May distract developers from real goals Stephan J. Schmidt, cintoo
  • 36. 36 Credits • Thanks to Zutubi for Pulse integration server • Thanks to cenqua for Clover code coverage • Thanks to Cedric for TestNG, Kent and Martin for JUnit • Thanks to the creators of the other tools • Tools used: IDEA, jMock, Pulse, Clover, Jemmy, TestNG/ JUnit, HSQL Stephan J. Schmidt, cintoo
  • 37. 37 References • Kent Beck, “The Future of Developer Testing”, SDForum 2004 • David Astels, “test-driven development - A Practical Guide”, 2003 • Steve Freeman, Nat Pryce, Tim Mackinnon, Joe Walnes, “Mock Roles, not Objects” Stephan J. Schmidt, cintoo
  • 38. Stephan J. Schmidt cintoo lead developer http://cintoo.org stephan@cintoo.org