SlideShare a Scribd company logo
Java course - IAG0040




            Unit testing &
     Agile Software Development




Anton Keks                           2011
Unit tests
 ●
     How to be confident that your code works?
 ●
     Why wait for somebody else to test your code?
 ●
     How to provide up-to-date examples on using your API?
 ●
     How to help yourself see your design better and therefore
     improve it?

                 The answer: write Unit Tests!!!

 ●   Unit tests are executable test cases for your modules (units),
     expressed in code
 ●
     Unit tests are executed automatically to ensure that your code
     still works after changing it (regression testing)
Java course – IAG0040                                         Lecture 6
Anton Keks                                                      Slide 2
Benefits of unit tests
 ●
     Unit testing isolates each module and shows that it is correct.
     It provides a strict written contract that the code must satisfy
 ●
     Facilitates change – unit tests provide regression testing,
     make refactoring safer
 ●   Simplifies integration – integration testing is easier, if
     parts are already proven to work correctly
 ●   Documentation – unit tests show how to use the API
 ●   Separation of interface from implementation – unit tests
     result in loosely coupled code



Java course – IAG0040                                          Lecture 6
Anton Keks                                                       Slide 3
A simple example
 ●   public class Concatenator {
        // this is a method under test
        public String concat(String a, String b) {
          return a + b;
        }

         // this is a simple test case
         public static void main(String[] args) {
           Concatenator c = new Concatenator();
           assert “abc123”.equals(
              c.concat(“abc”, “123”))
              : “concat() failed!”;
         }
     }

Java course – IAG0040                           Lecture 6
Anton Keks                                        Slide 4
JUnit
 ●
     JUnit is the first and most popular unit and regression
     testing framework for Java
 ●
     Is a 3rd-party jar file
     –   Obtainable from http://www.junit.org/
     –   Included and interfaced in IDEA, Eclipse, etc
 ●   JUnit 3
     –   older but still very popular
 ●   JUnit 4
     –   takes advantage of Java 5 features

Java course – IAG0040                                    Lecture 6
Anton Keks                                                 Slide 5
JUnit (cont)
 ●   JUnit 3
      –   must extend the junit.framework.TestCase class
      –   TestCase provides a lot of assertXXX() methods
      –   setUp() method is run before each test
      –   tearDown() method is run after each test
 ●   JUnit 4
      –   no extending is needed
      –   annotate test methods with @Test (from org.junit)
      –   assertXXX() methods may be statically imported
          import static org.junit.Assert.*;
      –   @Before and @After annotations replace setUp() and tearDown()

Java course – IAG0040                                           Lecture 6
Anton Keks                                                        Slide 6
JUnit 3 example
 ●   public class Concatenator {
        // this is a method under test
        public String concat(String a, String b) {
          return a + b;
        }
     }
     public class ConcatenatorTest extends TestCase{
        // this is a simple test case
        public void testConcat() {
          Concatenator c = new Concatenator();
          assertEquals(“concat() failed!”, “abc123”,
             c.concat(“abc”, “123”));
        }
     }

Java course – IAG0040                          Lecture 6
Anton Keks                                       Slide 7
JUnit 4 example
 ●   public class Concatenator {
        // this is a method under test
        public String concat(String a, String b) {
          return a + b;
        }
     }
     public class ConcatenatorTest {
        // this is a simple test case
        @Test
        public void testConcat() {
          Concatenator c = new Concatenator();
          assertEquals(“concat() failed!”, “abc123”,
             c.concat(“abc”, “123”));
        }
     }
Java course – IAG0040                          Lecture 6
Anton Keks                                       Slide 8
JUnit (cont)
 ●
     Naming convention
      –   Create at least one test class for each class, test classes usually
          have the Test suffix (e.g. DogTest)
      –   Generally, create one test method per method under test
          (e.g. @Test public void dogHasAName())
      –   Put tests into the the test directory (same package as the class
          under test, then you can access package local methods from
          tests)
 ●   JUnit runs all tests,
      –   defined in public void testXXX methods in classes extending
          TestCase, or
      –   annotated with @Test (no 'test' prefix please)

Java course – IAG0040                                                  Lecture 6
Anton Keks                                                               Slide 9
Mock objects in tests
 ●   Unit tests must isolate the unit under test (avoid dependencies)
 ●
     If an object under test uses other objects, they must be mocked
 ●   A mock object has the same interface as the real object, but
     different implementation (in many cases, it does nothing)
 ●   Real objects being mocked should have their own separate unit tests
 ●
     Possible implementations:
      –   Overriding: class MockDog extends Dog { ... }
      –   Anonymous classes: new Dog() { ... }
      –   Dynamic proxies: Proxy.newProxyInstance( ... )
          (see javadoc of java.lang.reflect.Proxy)
      –   Frameworks: mockito, easymock, mockobjects, jmock, etc

Java course – IAG0040                                               Lecture 6
Anton Keks                                                           Slide 10
Unit test tasks
 ●
     Write unit tests for these your classes using JUnit 4
     (see previous lectures' slides if you don't have them):
      –   Fibonacci, Factorial
      –   DuplicateRemoverImpl
      –   WordFrequencyCalculatorImpl
      –   ShapeAggregatorImpl
 ●   Use the above mentioned naming/coding convention
 ●   You no longer need main() methods in these classes
     which demonstrate that the code works – these were
     actually a sort of unit tests, too
Java course – IAG0040                                          Lecture 6
Anton Keks                                                      Slide 11
Agile Software Development
 ●
     Is a relatively new and more efficient software
     development methodology (process)
 ●
     Minimizes risks by splitting projects into small iterations
     that look like separate projects
      –   Each iteration includes all tasks to release an increment in
          functionality
           ●
               planning
           ●   requirements analysis
           ●   design & coding & testing
           ●   documentation



Java course – IAG0040                                                Lecture 6
Anton Keks                                                            Slide 12
Agile Manifesto
 ●
     http://www.agilemanifesto.org/
 ●   We are uncovering better ways of developing software by doing it
     and helping others do it. Through this work we have come to value:
      –   Individuals and interactions over processes and tools
      –   Working software over comprehensive documentation
      –   Customer collaboration over contract negotiation
      –   Responding to change over following a plan
 ●   That is, while there is value in the items on the right, we value the
     items on the left more.




Java course – IAG0040                                               Lecture 6
Anton Keks                                                           Slide 13
So what is Agile?
 ●   Way of creating software in lighter, faster, and people-centric way
 ●
     Adaptable, not predictable
 ●   Working software is the primary measure of success and is delivered
     frequently
 ●   Agile software development requires strict discipline
 ●
     Project team sits together (face-to-face communication)
      –   programmers and customers at minimum
      –   testers, designers, technical writers, managers
 ●   Changes in requirements are welcomed, not being afraid of




Java course – IAG0040                                             Lecture 6
Anton Keks                                                         Slide 14
Agile methodologies
 ●
     There are many (some existed before the Agile
     Manifesto)
     –   Scrum, Crystal Clear, Lean Software Development,
         XP (Extreme Programming), etc
 ●
     Bad (but often used) alternatives:
     –   Cowboy coding – no well-defined process
     –   Waterfall – most predictive, steps through
         requirements capture, analysis, design, coding,
         testing in a strict sequence
         (see www.waterfall2006.com fake conference site)

Java course – IAG0040                                Lecture 6
Anton Keks                                            Slide 15
Agile/XP project cycle
 ●
     Kick-off meeting
 ●   Iterations:
     –   Iteration planning meeting (a few hours)
     –   Daily stand-up meetings (max 15 min)
     –   Designing, coding, testing, communicating
 ●
     Fixed deadline ends (or customer decides to
     finish the project)



Java course – IAG0040                                Lecture 6
Anton Keks                                            Slide 16
User stories and iterations
 ●
     User stories are written on small paper chunks
 ●   They are are added/removed/prioritized during iteration planning
     meetings
 ●   Each user story is estimated in abstract units
 ●
     Team's velocity is calculated
     after each iteration
 ●   Next iteration plan must be
     the same number of units
     completed during the
     previous iteration
 ●
     After a few iterations,
     velocity stabilizes
Java course – IAG0040                                        Lecture 6
Anton Keks                                                    Slide 17
TDD (Test Driven Development)
 ●
     TDD is one of the main practices of XP (Extreme Programming)
 ●   TDD = TFD + refactoring
 ●
     TFD (Test First Development) means
      –   Write tests before the real (functional) code
      –   Write real code only to satisfy failing tests
      –   Eliminate duplication
 ●   Refactoring means redesigning the code without changing or
     braking existing functionality
      –   always ensure that you have the simplest design possible for the
          functionality built to date



Java course – IAG0040                                              Lecture 6
Anton Keks                                                          Slide 18
TDD benefits
 ●   Code is written in small steps
 ●
     You design your API before writing code, which results in better and
     loosely coupled object model
 ●   You get 100% unit test coverage
 ●   After each test-code iteration you get a working code, you can
     virtually stop anytime
 ●   You don't waste time designing beforehand; initial designs cannot
     predict everything
 ●
     You can change anything anytime (because requirements always
     change)
 ●
     Overengineering is eliminated


Java course – IAG0040                                             Lecture 6
Anton Keks                                                         Slide 19
Pair Programming
 ●
     Pair Programming means there are two programmers sitting
     and working together
 ●   Pairs help stay on track with TDD
 ●   Pairing helps to learn from each other
 ●   Instant (extreme) code review
 ●   Two people produce better ideas than any of them could alone
 ●   “Ping-pong” allows to turn development into a game
      –   Implement failing test, write a new test, pass keyboard




Java course – IAG0040                                         Lecture 6
Anton Keks                                                     Slide 20
Continuous integration
 ●   Regular automated builds of the software (e.g. after each commit)
           –   the whole program is recompiled
           –   automated (unit) tests are run
           –   documentation is generated
           –   software is packaged and therefore ready to run
 ●
     Provides short feedback to developers
 ●   Helps to find integration problems and failed tests early
 ●
     The latest builds are always runnable and testable by e.g. customers
 ●   Hudson is one of the tools used for this purpose
           –   see http://java.azib.net/hudson

Java course – IAG0040                                            Lecture 6
Anton Keks                                                        Slide 21
Hands-on: TDD Bowling
 ●
     Rules/Requirements of 10-pin bowling:
           –   A game of 10 frames (2 shots per frame)
           –   Total score = sum of scores of all frames
           –   Spare – all 10 pins are hit with two shots (frame)
                        ●   Frame score += next shot (bonus)
           –   Strike – all 10 pins are hit with one shot
                        ●   Frame score += two next shots (bonus)
           –   If last frame hits all pins, extra shot is awarded
           –   Perfect game = 12 strikes = 300 points

Java course – IAG0040                                               Lecture 6
Anton Keks                                                           Slide 22

More Related Content

What's hot

Java Course 13: JDBC & Logging
Java Course 13: JDBC & LoggingJava Course 13: JDBC & Logging
Java Course 13: JDBC & Logging
Anton Keks
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
Kernel Training
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
Vskills
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
eMexo Technologies
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
Core java
Core java Core java
Core java
Ravi varma
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
PravinYalameli
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Singsys Pte Ltd
 
Core java
Core javaCore java
Core java
kasaragaddaslide
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Ajay Sharma
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Sagar Verma
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)
Stephen Colebourne
 
Java training in delhi
Java training in delhiJava training in delhi
Java training in delhi
APSMIND TECHNOLOGY PVT LTD.
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 

What's hot (20)

Java Course 13: JDBC & Logging
Java Course 13: JDBC & LoggingJava Course 13: JDBC & Logging
Java Course 13: JDBC & Logging
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
 
Core Java Certification
Core Java CertificationCore Java Certification
Core Java Certification
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
 
Core java
Core java Core java
Core java
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Core java
Core javaCore java
Core java
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Java basic
Java basicJava basic
Java basic
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)
 
Java training in delhi
Java training in delhiJava training in delhi
Java training in delhi
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 

Viewers also liked

Agile in a Nutshell
Agile in a NutshellAgile in a Nutshell
Agile in a Nutshell
Portia Tung
 
Technical Recruitment Overview & Tips
Technical Recruitment Overview & TipsTechnical Recruitment Overview & Tips
Technical Recruitment Overview & Tips
UmaShanker Akharia ~ U.S.A.
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
SAMIR BHOGAYTA
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 
Overview of Agile Methodology
Overview of Agile MethodologyOverview of Agile Methodology
Overview of Agile MethodologyHaresh Karkar
 

Viewers also liked (7)

Agile in a Nutshell
Agile in a NutshellAgile in a Nutshell
Agile in a Nutshell
 
Technical Recruitment Overview & Tips
Technical Recruitment Overview & TipsTechnical Recruitment Overview & Tips
Technical Recruitment Overview & Tips
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Overview of Agile Methodology
Overview of Agile MethodologyOverview of Agile Methodology
Overview of Agile Methodology
 

Similar to Java Course 6: Introduction to Agile

Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Dan Allen
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
Anton Keks
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
Davide Fella
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
Anatoliy Okhotnikov
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep Learning
Shelley Lambert
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
VMware Tanzu
 
Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and phpTho Q Luong Luong
 
The_Little_Jenkinsfile_That_Could
The_Little_Jenkinsfile_That_CouldThe_Little_Jenkinsfile_That_Could
The_Little_Jenkinsfile_That_Could
Shelley Lambert
 
Test it! Unit, mocking and in-container Meet Arquillian!
Test it! Unit, mocking and in-container Meet Arquillian!Test it! Unit, mocking and in-container Meet Arquillian!
Test it! Unit, mocking and in-container Meet Arquillian!
Ivan Ivanov
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
Himanshu
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
Onkar Deshpande
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
Ortus Solutions, Corp
 
Intro to junit
Intro to junitIntro to junit
Intro to junit
Rakesh Srivastava
 
Presentation sem 1.pptx
Presentation sem 1.pptxPresentation sem 1.pptx
Presentation sem 1.pptx
dendi65
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junitjborden33
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1jborden33
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java Platform
Peter Pilgrim
 
Junit
JunitJunit
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
Dicoding
 
Ci/CD Android
Ci/CD AndroidCi/CD Android
Ci/CD Android
rendra toro
 

Similar to Java Course 6: Introduction to Agile (20)

Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Introduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibusIntroduzione a junit + integrazione con archibus
Introduzione a junit + integrazione con archibus
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep Learning
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
Introduction to test automation in java and php
Introduction to test automation in java and phpIntroduction to test automation in java and php
Introduction to test automation in java and php
 
The_Little_Jenkinsfile_That_Could
The_Little_Jenkinsfile_That_CouldThe_Little_Jenkinsfile_That_Could
The_Little_Jenkinsfile_That_Could
 
Test it! Unit, mocking and in-container Meet Arquillian!
Test it! Unit, mocking and in-container Meet Arquillian!Test it! Unit, mocking and in-container Meet Arquillian!
Test it! Unit, mocking and in-container Meet Arquillian!
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
 
Intro to junit
Intro to junitIntro to junit
Intro to junit
 
Presentation sem 1.pptx
Presentation sem 1.pptxPresentation sem 1.pptx
Presentation sem 1.pptx
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junit
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java Platform
 
Junit
JunitJunit
Junit
 
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
Continuous Integration & Continuous Delivery on Android - Nur Rendra Toro Sin...
 
Ci/CD Android
Ci/CD AndroidCi/CD Android
Ci/CD Android
 

More from Anton Keks

Being a professional software tester
Being a professional software testerBeing a professional software tester
Being a professional software tester
Anton Keks
 
Java Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUIJava Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUI
Anton Keks
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
Anton Keks
 
Java Course 9: Networking and Reflection
Java Course 9: Networking and ReflectionJava Course 9: Networking and Reflection
Java Course 9: Networking and Reflection
Anton Keks
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
Choose a pattern for a problem
Choose a pattern for a problemChoose a pattern for a problem
Choose a pattern for a problem
Anton Keks
 
Simple Pure Java
Simple Pure JavaSimple Pure Java
Simple Pure Java
Anton Keks
 
Database Refactoring
Database RefactoringDatabase Refactoring
Database Refactoring
Anton Keks
 
Scrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerScrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineer
Anton Keks
 
Being a Professional Software Developer
Being a Professional Software DeveloperBeing a Professional Software Developer
Being a Professional Software Developer
Anton Keks
 

More from Anton Keks (10)

Being a professional software tester
Being a professional software testerBeing a professional software tester
Being a professional software tester
 
Java Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUIJava Course 14: Beans, Applets, GUI
Java Course 14: Beans, Applets, GUI
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
 
Java Course 9: Networking and Reflection
Java Course 9: Networking and ReflectionJava Course 9: Networking and Reflection
Java Course 9: Networking and Reflection
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Choose a pattern for a problem
Choose a pattern for a problemChoose a pattern for a problem
Choose a pattern for a problem
 
Simple Pure Java
Simple Pure JavaSimple Pure Java
Simple Pure Java
 
Database Refactoring
Database RefactoringDatabase Refactoring
Database Refactoring
 
Scrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerScrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineer
 
Being a Professional Software Developer
Being a Professional Software DeveloperBeing a Professional Software Developer
Being a Professional Software Developer
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 

Java Course 6: Introduction to Agile

  • 1. Java course - IAG0040 Unit testing & Agile Software Development Anton Keks 2011
  • 2. Unit tests ● How to be confident that your code works? ● Why wait for somebody else to test your code? ● How to provide up-to-date examples on using your API? ● How to help yourself see your design better and therefore improve it? The answer: write Unit Tests!!! ● Unit tests are executable test cases for your modules (units), expressed in code ● Unit tests are executed automatically to ensure that your code still works after changing it (regression testing) Java course – IAG0040 Lecture 6 Anton Keks Slide 2
  • 3. Benefits of unit tests ● Unit testing isolates each module and shows that it is correct. It provides a strict written contract that the code must satisfy ● Facilitates change – unit tests provide regression testing, make refactoring safer ● Simplifies integration – integration testing is easier, if parts are already proven to work correctly ● Documentation – unit tests show how to use the API ● Separation of interface from implementation – unit tests result in loosely coupled code Java course – IAG0040 Lecture 6 Anton Keks Slide 3
  • 4. A simple example ● public class Concatenator { // this is a method under test public String concat(String a, String b) { return a + b; } // this is a simple test case public static void main(String[] args) { Concatenator c = new Concatenator(); assert “abc123”.equals( c.concat(“abc”, “123”)) : “concat() failed!”; } } Java course – IAG0040 Lecture 6 Anton Keks Slide 4
  • 5. JUnit ● JUnit is the first and most popular unit and regression testing framework for Java ● Is a 3rd-party jar file – Obtainable from http://www.junit.org/ – Included and interfaced in IDEA, Eclipse, etc ● JUnit 3 – older but still very popular ● JUnit 4 – takes advantage of Java 5 features Java course – IAG0040 Lecture 6 Anton Keks Slide 5
  • 6. JUnit (cont) ● JUnit 3 – must extend the junit.framework.TestCase class – TestCase provides a lot of assertXXX() methods – setUp() method is run before each test – tearDown() method is run after each test ● JUnit 4 – no extending is needed – annotate test methods with @Test (from org.junit) – assertXXX() methods may be statically imported import static org.junit.Assert.*; – @Before and @After annotations replace setUp() and tearDown() Java course – IAG0040 Lecture 6 Anton Keks Slide 6
  • 7. JUnit 3 example ● public class Concatenator { // this is a method under test public String concat(String a, String b) { return a + b; } } public class ConcatenatorTest extends TestCase{ // this is a simple test case public void testConcat() { Concatenator c = new Concatenator(); assertEquals(“concat() failed!”, “abc123”, c.concat(“abc”, “123”)); } } Java course – IAG0040 Lecture 6 Anton Keks Slide 7
  • 8. JUnit 4 example ● public class Concatenator { // this is a method under test public String concat(String a, String b) { return a + b; } } public class ConcatenatorTest { // this is a simple test case @Test public void testConcat() { Concatenator c = new Concatenator(); assertEquals(“concat() failed!”, “abc123”, c.concat(“abc”, “123”)); } } Java course – IAG0040 Lecture 6 Anton Keks Slide 8
  • 9. JUnit (cont) ● Naming convention – Create at least one test class for each class, test classes usually have the Test suffix (e.g. DogTest) – Generally, create one test method per method under test (e.g. @Test public void dogHasAName()) – Put tests into the the test directory (same package as the class under test, then you can access package local methods from tests) ● JUnit runs all tests, – defined in public void testXXX methods in classes extending TestCase, or – annotated with @Test (no 'test' prefix please) Java course – IAG0040 Lecture 6 Anton Keks Slide 9
  • 10. Mock objects in tests ● Unit tests must isolate the unit under test (avoid dependencies) ● If an object under test uses other objects, they must be mocked ● A mock object has the same interface as the real object, but different implementation (in many cases, it does nothing) ● Real objects being mocked should have their own separate unit tests ● Possible implementations: – Overriding: class MockDog extends Dog { ... } – Anonymous classes: new Dog() { ... } – Dynamic proxies: Proxy.newProxyInstance( ... ) (see javadoc of java.lang.reflect.Proxy) – Frameworks: mockito, easymock, mockobjects, jmock, etc Java course – IAG0040 Lecture 6 Anton Keks Slide 10
  • 11. Unit test tasks ● Write unit tests for these your classes using JUnit 4 (see previous lectures' slides if you don't have them): – Fibonacci, Factorial – DuplicateRemoverImpl – WordFrequencyCalculatorImpl – ShapeAggregatorImpl ● Use the above mentioned naming/coding convention ● You no longer need main() methods in these classes which demonstrate that the code works – these were actually a sort of unit tests, too Java course – IAG0040 Lecture 6 Anton Keks Slide 11
  • 12. Agile Software Development ● Is a relatively new and more efficient software development methodology (process) ● Minimizes risks by splitting projects into small iterations that look like separate projects – Each iteration includes all tasks to release an increment in functionality ● planning ● requirements analysis ● design & coding & testing ● documentation Java course – IAG0040 Lecture 6 Anton Keks Slide 12
  • 13. Agile Manifesto ● http://www.agilemanifesto.org/ ● We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: – Individuals and interactions over processes and tools – Working software over comprehensive documentation – Customer collaboration over contract negotiation – Responding to change over following a plan ● That is, while there is value in the items on the right, we value the items on the left more. Java course – IAG0040 Lecture 6 Anton Keks Slide 13
  • 14. So what is Agile? ● Way of creating software in lighter, faster, and people-centric way ● Adaptable, not predictable ● Working software is the primary measure of success and is delivered frequently ● Agile software development requires strict discipline ● Project team sits together (face-to-face communication) – programmers and customers at minimum – testers, designers, technical writers, managers ● Changes in requirements are welcomed, not being afraid of Java course – IAG0040 Lecture 6 Anton Keks Slide 14
  • 15. Agile methodologies ● There are many (some existed before the Agile Manifesto) – Scrum, Crystal Clear, Lean Software Development, XP (Extreme Programming), etc ● Bad (but often used) alternatives: – Cowboy coding – no well-defined process – Waterfall – most predictive, steps through requirements capture, analysis, design, coding, testing in a strict sequence (see www.waterfall2006.com fake conference site) Java course – IAG0040 Lecture 6 Anton Keks Slide 15
  • 16. Agile/XP project cycle ● Kick-off meeting ● Iterations: – Iteration planning meeting (a few hours) – Daily stand-up meetings (max 15 min) – Designing, coding, testing, communicating ● Fixed deadline ends (or customer decides to finish the project) Java course – IAG0040 Lecture 6 Anton Keks Slide 16
  • 17. User stories and iterations ● User stories are written on small paper chunks ● They are are added/removed/prioritized during iteration planning meetings ● Each user story is estimated in abstract units ● Team's velocity is calculated after each iteration ● Next iteration plan must be the same number of units completed during the previous iteration ● After a few iterations, velocity stabilizes Java course – IAG0040 Lecture 6 Anton Keks Slide 17
  • 18. TDD (Test Driven Development) ● TDD is one of the main practices of XP (Extreme Programming) ● TDD = TFD + refactoring ● TFD (Test First Development) means – Write tests before the real (functional) code – Write real code only to satisfy failing tests – Eliminate duplication ● Refactoring means redesigning the code without changing or braking existing functionality – always ensure that you have the simplest design possible for the functionality built to date Java course – IAG0040 Lecture 6 Anton Keks Slide 18
  • 19. TDD benefits ● Code is written in small steps ● You design your API before writing code, which results in better and loosely coupled object model ● You get 100% unit test coverage ● After each test-code iteration you get a working code, you can virtually stop anytime ● You don't waste time designing beforehand; initial designs cannot predict everything ● You can change anything anytime (because requirements always change) ● Overengineering is eliminated Java course – IAG0040 Lecture 6 Anton Keks Slide 19
  • 20. Pair Programming ● Pair Programming means there are two programmers sitting and working together ● Pairs help stay on track with TDD ● Pairing helps to learn from each other ● Instant (extreme) code review ● Two people produce better ideas than any of them could alone ● “Ping-pong” allows to turn development into a game – Implement failing test, write a new test, pass keyboard Java course – IAG0040 Lecture 6 Anton Keks Slide 20
  • 21. Continuous integration ● Regular automated builds of the software (e.g. after each commit) – the whole program is recompiled – automated (unit) tests are run – documentation is generated – software is packaged and therefore ready to run ● Provides short feedback to developers ● Helps to find integration problems and failed tests early ● The latest builds are always runnable and testable by e.g. customers ● Hudson is one of the tools used for this purpose – see http://java.azib.net/hudson Java course – IAG0040 Lecture 6 Anton Keks Slide 21
  • 22. Hands-on: TDD Bowling ● Rules/Requirements of 10-pin bowling: – A game of 10 frames (2 shots per frame) – Total score = sum of scores of all frames – Spare – all 10 pins are hit with two shots (frame) ● Frame score += next shot (bonus) – Strike – all 10 pins are hit with one shot ● Frame score += two next shots (bonus) – If last frame hits all pins, extra shot is awarded – Perfect game = 12 strikes = 300 points Java course – IAG0040 Lecture 6 Anton Keks Slide 22