Powerpoint Templates Page 1 Powerpoint Templates Unit Testing Ari Seppi

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

SPL/2010 Test-Driven Development (TDD) 1. SPL/
Test process essentials Riitta Viitamäki,
Jump into Release 1 Pepper. Goals for End of Class Project delivery Diagrams (new class & firm state, use, context, sequence) Agile cycles with SCRUM.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Testing and Debugging CS221 – 2/13/09. Airline Program.
1 CODE TESTING Principles and Alternatives. 2 Testing - Basics goal - find errors –focus is the source code (executable system) –test team wants to achieve.
1 Software Testing and Quality Assurance Lecture 15 - Planning for Testing (Chapter 3, A Practical Guide to Testing Object- Oriented Software)
Karlstad University Computer Science Design Contracts and Error Management Design Contracts and Errors A Software Development Strategy (anpassad för PUMA)
Fundamentals of Information Systems, Second Edition
Applied Software Project Management Andrew Stellman & Jennifer Greene Applied Software Project Management Applied Software.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Swami NatarajanJuly 14, 2015 RIT Software Engineering Reliability: Introduction.
Software Testing Name: Madam Currie Course: Swen5431 Semester: Summer 2K.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Study Tips for COP 4531 Ashok Srinivasan Computer Science, Florida State University Aim: To suggest learning techniques that will help you do well in this.
WorkPlace Pro Utilities.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
TESTING.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Chapter 22 Developer testing Peter J. Lane. Testing can be difficult for developers to follow  Testing’s goal runs counter to the goals of the other.
Software Construction Lecture 18 Software Testing.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Refactoring & Testability. Testing in OOP programming No life in flexible methodologies and for refactoring- infected developers without SOME kind of.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Black Box Testing : The technique of testing without having any knowledge of the interior workings of the application is Black Box testing. The tester.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Software Engineering Saeed Akhtar The University of Lahore.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Dynamic Testing.
Unit Testing with FlexUnit
Northwest Arkansas.Net User Group Jay Smith Tyson Foods, Inc. Unit Testing nUnit, nUnitAsp, nUnitForms.
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
Your current Moodle 1.9 Minimum Requirements Ability to do a TEST RUN! Upgrading Moodle to Version 2 By Ramzan Jabbar Doncaster College for the Deaf By.
START Application Spencer Johnson Jonathan Barella Cohner Marker.
Automated Testing with PHPUnit. How do you know your code works?
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
Unit Testing with JUnit Dan Fleck Fall 2007 (For both CS211 and 421… two birds… one lecture! :-)
Data Virtualization Tutorial: Introduction to SQL Script
John D. McGregor Session 9 Testing Vocabulary
SAP Business One B1iF Training
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Chapter 13 & 14 Software Testing Strategies and Techniques
John D. McGregor Session 9 Testing Vocabulary
John D. McGregor Session 9 Testing Vocabulary
History, Characteristics and Frameworks
JCL Standards #5 Company Name
Higher-Level Testing and Integration Testing
Unit Testing with JUnit
Unit Testing with JUnit
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Chapter 13: Construction
Developing and testing enterprise Java applications
Tonga Institute of Higher Education IT 141: Information Systems
Automated test.
Applying Use Cases (Chapters 25,26)
Tonga Institute of Higher Education IT 141: Information Systems
Test Cases, Test Suites and Test Case management systems
Overview Activities from additional UP disciplines are needed to bring a system into being Implementation Testing Deployment Configuration and change management.
Automated test.
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

Powerpoint Templates Page 1 Powerpoint Templates Unit Testing Ari Seppi

Powerpoint Templates Page 2 Agenda -Basic introductory to unit testing -What is unit testing? -Why to unit test? -When to unit test? -How to unit test? -Practical examples -PHP and databases -Even more practical exercise

Powerpoint Templates Page 3 So? What Is It? -White box testing -The test developer has knowledge about implementation details. -Usually the same developer writes the functionality and unit tests to test it. -Testing of a single unit of an application. -A class is a natural scope in object oriented languages and a module in procedural languages.

Powerpoint Templates Page 4 What Can Be Tested With It? -Since scope of a test was single class, the tested functionality is also limited to it. -Data structures -Execution paths -Invalid parameters -One problem is figuring out when the testing is good enough. -Naturally it is often not even possible to test function with all the possible parameter values. -Dynamically typed languages bring their own problems to the mix as there is no compiler level parameter type checking.

Powerpoint Templates Page 5 Why? -Low level unit tests are easy to automate as opposed to higher level user interface tests. -Unit test force developers to think the code through one more time and so reveal error prone parts of the code at the early stage. -Fixing early saves money and work hours and not fixing something might cost even more.

Powerpoint Templates Page 6 When? -Test driven development -Unit testing suits especially well for writing the tests before the actual so that the code can be tested as soon as its ready. -But writing the tests immediately after the implementation works as well. -Making the tests in some undefined future is a pretty sure way of not doing them at all.

Powerpoint Templates Page 7 How? -Many languages already have unit testing frameworks. -JUnit, PHPUnit etc. -The unit tests are very easily automated so they are often run in project’s continous integration system. -Unit testing can be used to test most of the API level issues like the interfaces and data structures -What if the methods are used in a wrong way? -How are error situations handled?

Powerpoint Templates Page 8 How? – Object Oriented Languages -Object oriented languages: In practice tests are arranged into test case classes based on the classes on the system under test. -A simple single tests covers a single method/function more complicated test cases can cover state changed by calling functions consecutively.

Powerpoint Templates Page 9 How? – But units have relations -One of the problems in test unit creation lies in the external relations to other units and functionality outside our own code all together. -Libraries -Data sources such as databases -To solve the problem we need to emulate the outside world. -Stubs, mocks and fakes -Test beds (includes hardware) and harnesses (testing framework)

Powerpoint Templates Page 10 How? – Code Coverage -Code coverage tells us how much of the code is involved in the test cases. -If a function has 50 different paths of execution and one of them gets tested, the tests cannot say much about the actual quality of the code. -Of course one path of execution might be the one taken by 99% of the real life executions. -Testing all the possible executions is often more than the project schedule allows for. -And even if you test all the paths of execution, unexpected function parameters may create new error situations even on the tested paths.

Powerpoint Templates Page 11 Summary of the Basics -Unit tests are created by developers, usually by the developer who wrote the tested code, and executed by any developer who modifies the code. -Or in practice often in continous integration systems. -We should unit test since it saves time in the future. -Often it is impossible to test all the possible cases so it is important to see which cases need to be tested.

Powerpoint Templates Page 12 Let’s Get Practical - -Username: redmine -Password: 15c3d75f8019f18af08aeaf24f5ba37e - -Username: TestProject -Password: testunitproject - ex/robotwarhttp://jenkins.sis.uta.fi/sonar/dashboard/ind ex/robotwar

Powerpoint Templates Page 13 Testing Databases -Unit tests should be relatively fast to execute but exporting large test data sets for to databases can take time. -One solution could be using in-memory databases but with them we have the problem that they do not function exactly like the actual production database. -One solution could be performing some standard model tests in in-memory database.

Powerpoint Templates Page 14 Exercise -Study file testi/PHPTest/robotwar/model/RobotUtils.ph phttps://svn.sis.uta.fi/jenkins- testi/PHPTest/robotwar/model/RobotUtils.ph p -Create a unit test file for it in file RobotUtils[student_number]Test.php to the appropriate directory.

Powerpoint Templates Page 15 Exercise 2 -Study file testi/PHPTest/robotwar/model/RobotManager.phphttps://svn.sis.uta.fi/jenkins- testi/PHPTest/robotwar/model/RobotManager.php -Create a unit test file for function saveRobots in file RobotManager[student_number]Test.p hp to the appropriate directory.

Powerpoint Templates Page 16 References and More Reading -Testing course at TUT (in Finnish) _2013.pdf _2013.pdf -Testing with PHPUnit introduction-to-phpunit/ introduction-to-phpunit/ introduction-to-phpunit/ introduction-to-phpunit/ -Testing PHP/MySQL Applications with PHPUnit/DBUnit ment/1980%E2%80%8E ment/1980%E2%80%8E