Principles of Object Oriented Programming

Slides:



Advertisements
Similar presentations
MAHDI OMAR JUNIT TUTORIAL. CONTENTS Installation of Junit Eclipse support for Junit Using Junit exercise JUnit options Questions Links and Literature.
Advertisements

Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
JUnit test distribution Bettina Scharpf ACM 2 University of Applied Science Furtwangen.
WISTPC-09 : Session A Tariq M. King PhD Candidate Florida International University Workshop on Integrating Software Testing into Programming.
Testing and Debugging CS221 – 2/13/09. Airline Program.
JUnit. Why is testing good? Due to psychological factors, programmers are bad testers. A computer can test much faster than a human Philosophy: “If it.
TDD Test-Driven Development. JUnit 4.0 To use annotations need to import org.junit.Test To use assertion need to import org.junit.Assert.* No need to.
Unit testing C# classes “If it isn’t tested it doesn’t work” Unit testing C# classes1.
 What is Software Testing  Terminologies used in Software testing  Types of Testing  What is Manual Testing  Types of Manual Testing  Process that.
Unit testing Java programs1 Unit testing Java programs Using JUnit 4 “If it isn't tested, it doesn’t work”
Ranga Rodrigo. Class is central to object oriented programming.
© Dr. A. Williams, Fall Present Software Quality Assurance – JUnit Lab 1 JUnit A unit test framework for Java –Authors: Erich Gamma, Kent Beck Objective:
BY: GARIMA GUPTA MCA FINAL YEAR WHAT IS SOFTWARE TESTING ? SOFTWARE TESTING IS THE PROCESS OF EXECUTING PROGRAMS OR SYSTEM WITH THE INTENT.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Unit Testing.
JUnit The framework. Goal of the presentation showing the design and construction of JUnit, a piece of software with proven value.
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Software Testing. Introduction Testing is often left to the end of the project which is generally not a good idea. Testing should be conducted throughout.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
Principles of Object Oriented Programming Practical session 2 – part A.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
Testing in Extreme Programming
Unit and Functional Testing Your Flex Applications Mike Nimer Dir. Of Engineering nomee.com.
Software Testing. What is Software Testing? Definition: 1.is an investigation conducted to provide stakeholders with information about the quality of.
SENG 301 – Tutorial 1 Introduction to Eclipse, Subclipse, and JUnit Slides: Theodore D. Hellmann.
CSC 216/001 Lecture 4. Unit Testing  Why is it called “unit” testing?  When should tests be written?  Before the code for a class is written.  After.
JUnit & Eclipse1 DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY Feb 2, 2009 revision 1.2 – Feb 2, 2009 by Emil Vassev & Joey.
Test automation / JUnit Building automatically repeatable test suites.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
JUnit Dwight Deugo Nesa Matic
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
JUnit Adam Heath. What is JUnit?  JUnit is a unit testing framework for the Java programming language  It allows developers to swiftly and easily test.
JUnit Dwight Deugo Nesa Matic
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
By Rick Mercer with help from Kent Beck and Scott Ambler Java Review via Test Driven Development (TDD)
EMBEDDED REAL-TIME, INC. December 8, 2015 Java Unit Mark Mosher Rochester Java Users Group.
JUnit Don Braffitt Updated: 10-Jun-2011.
JUnit Eclipse, Java and introduction to Junit. Topics Covered  Using Eclipse IDE  Example Java Programs  Junit Introduction.
JUnit. Introduction JUnit is an open source Java testing framework used to write and run repeatable tests JUnit is integrated with several IDEs, including.
Software Engineering Saeed Akhtar The University of Lahore.
S Ramakrishnan1 Systems V & V, Quality and Standards Dr Sita Ramakrishnan School CSSE Monash University.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved.
CPSC 871 John D. McGregor Module 8 Session 2 JUnit.
Unit testing Java programs1 Unit testing Java programs Using JUnit 4 “If it isn't tested, it doesn’t work”
CS-2852 Data Structures LECTURE 7B Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
Unit Testing (Lab 6) Tool Junit on Eclipse SDK By Asst.Prof.Dr. Wararat Songpan(Rungworawut) Software Testing Department of Computer Science, Faculty.
Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests. The first step,
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Subject Name: Software Testing Subject Code: 10CS842 Prepared By:
Unit Testing.
Software Construction Lab 10 Unit Testing with JUnit
Don Braffitt Updated: 26-Mar-2013
SENG 301 – Tutorial 1 Introduction to Eclipse, Subclipse, and JUnit
Introduction to JUnit CS 4501 / 6501 Software Testing
Unit testing Java programs Using JUnit
Software Testing Software testing.
Session 2 What you already know about Java Reading and using an API
Unit testing C# classes
Lecture 09:Software Testing
Verification and Validation Unit Testing
Credit to Eclipse Documentation
Introduction to JUnit CS 4501 / 6501 Software Testing
Introduction to JUnit IT323 – Software Engineering II
Testing Acknowledgement: Original slides by Jory Denny.
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Joel Adams and Jeremy Frens Calvin College
JUnit Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from the Eclipse 3.0 and.
UNIT TESTING TOOLS Workshop on Integrating Software
Presentation transcript:

Principles of Object Oriented Programming Practical session 2 – part A

Testing The importance of testing: Tests represent requirements: Ensure that product works as user expected.  Reduced costs: By discover defects early in the software life cycle. Program Managers often say: “Testing is too expensive.” Not testing is even more expensive You’re going to spend about half of your development budget on testing, whether you want to or not.

Testing methods White-box testing : Black-box testing : Tests internal structures or workings of a program Black-box testing : Examining functionality without any knowledge of internal implementation. Grey-box testing : Involves having knowledge of internal data structures and algorithms for purposes of designing tests, while executing those tests at the user, or black-box level.

Testing levels Unit testing: Integration testing: System testing: The testing of individual software components. Integration testing: Integration testing is any type of software testing that seeks to verify the interfaces between components against a software design. System testing: Tests a completely integrated system to verify that it meets its requirements. Acceptance testing: Test conducted to determine if the requirements of a specification or contract  are met. 

JUnit JUnit is a testing framework written by Erich Gamma and Kent Beck. It is used by developers who implement unit tests in Java. JUnit is Open Source Software.

Using Eclipse To setup JUnit in Eclipse: Open eclipse. Right click on project. Click on property. Build Path. Configure Build Path and add the junit-4 in the libraries using “Add Libraries…” button.

Using Intellij

Creating a test To test a project: Create a test class on a different package in the project. Import the JUnit package: import org.junit.* Write test using the tags: @Before: Setup the testing object. @Test: The code testing the code. @After: Cleaning up after the test end. Use Asserts function to test the code. Take a look at the Junit API: http://junit.sourceforge.net/javadoc/org/junit/Assert.html

The Junit API

A code to test: package main_pkg; public class Operations { public double div(double x, double y) { if (y == 0) throw new RuntimeException("Can't divide by zero"); return x/y; } {

Writing tests package tests; import main_pkg.Operations; import org.junit.Assert; import org.junit.Before; import org.junit.Test; public class OperationsTests { private Operations obj; @Before public void createSub() { obj = new Operations(); } @Test public void testDiv1() { Assert.assertEquals("8 / 4 should be 2", obj.div(8, 4), 2, 0.01); { public void testDiv2() { try { obj.div(10, 0); Assert.fail("Exception expected"); catch (Exception e) { // Success } import org.junit.*;