CPSC 871 John D. McGregor Module 8 Session 2 JUnit.

Slides:



Advertisements
Similar presentations
Java Testing Tools. junit is a testing harness for unit testing. emma is a code coverage tool. The tools can be used in concert to provide statement and.
Advertisements

METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Overview of Data Structures and Algorithms
T ESTING WITH J UNIT IN E CLIPSE Farzana Rahman. I NTRODUCTION The class that you will want to test is created first so that Eclipse will be able to find.
JUnit Automated Software Testing Framework Paul Ammann & Jeff Offutt Thanks in part to Aynur Abdurazik.
JUnit intro Kalvis Apsitis. What are “Programmer Tests”? Programmer Testing is the testing performed by a developer with the goal of verifying the correct.
Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
JUnit Automated Software Testing Framework Paul Ammann & Jeff Offutt Thanks in part to Aynur Abdurazik.
Modularity. Methods & Class as program unit A method is comprised of statement sequences and is often viewed as the smallest program unit to be considered.
Fall 2007CS 2251 Programming Tools Eclipse JUnit Testing make and ant.
20-Jun-15 More About JUnit. Test suites A test suite is a group of JUnit tests You can create a test suite in Eclipse as follows: File  New  Other...
Java ThreadsGraphics Programming Graphics Programming: Java Threads.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
Ranga Rodrigo. Class is central to object oriented programming.
Software Development Tools COMP220 Seb Coope Week 8 Lecture 1 Ant, Testing and JUnit (2) These slides are mainly based on “Java Development with Ant” -
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Principles of Object Oriented Programming Practical session 2 – part A.
Testing with Android Part I of II. Android Testing Framework Based on JUnit The Android JUnit extensions provide component-specific test case classes.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Continuous QA Sewit Adams (Colorado State University) Bin Gao (Michigan State University) Jerry Neal (Indiana University)
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Test automation / JUnit Building automatically repeatable test suites.
JUnit test and Project 3 simulation. 2 JUnit The testing problems The framework of JUnit A case study Acknowledgement: using some materials from JUNIT.
CPSC 871 John D. McGregor Module 2 Session 4 CMMI & assignment.
CPSC 871 John D. McGregor Module 7 Session 1 More UML.
Programming in R SQL in R. Running SQL in R In this session I will show you how to: Run basic SQL commands within R.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
JUnit. Introduction JUnit is an open source Java testing framework used to write and run repeatable tests JUnit is integrated with several IDEs, including.
1 Unit Testing with JUnit CS 3331 JUnit website at Kent Beck and Eric Gamma. Test Infected: Programmers Love Writing Tests, Java Report,
Intoduction to Unit Testing Using JUnit to structure Unit Testing SE-2030 Dr. Mark L. Hornick 1.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved.
Parallel Processing (CS526) Spring 2012(Week 8).  Shared Memory Architecture  Shared Memory Programming & PLs  Java Threads  Preparing the Environment.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
CPSC 871 John D. McGregor Process – an introduction Module 0 Session 3.
Unit, Regression, and Behavioral Testing Based On: Unit Testing with JUnit and CUnit by Beth Kirby Dec 13, 2002 Jules.
CPSC 372 John D. McGregor More EPF Module 2 Session 4.
Test a Little, Code a Little Colin Sharples IBM Global Services New Zealand Colin Sharples IBM Global Services New Zealand.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
CPSC 871 John D. McGregor Module 8 Session 3 Assignment.
CPSC 372 John D. McGregor Module 1 Session 2 Process Measurement.
Interacting with LexEVS 5.0 LexEVS in a Distributed Environment November 2009.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
CPSC 872 John D. McGregor Session 13 Process. Specification and design problem solution specification implementation specification.
John D. McGregor Session 9 Testing Vocabulary
JUnit Automated Software Testing Framework
John D. McGregor Eclipse Process Framework Module 2 Session 4
Introduction to JUnit CS 4501 / 6501 Software Testing
Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model.
This presentation is created for the course COP4331 at UCF
Java Programming Language
Why should we test? How should we test?
Packages, Interfaces & Exception Handling
John D. McGregor Session 9 Testing Vocabulary
Junit with.
John D. McGregor Session 9 Testing Vocabulary
JUnit Automated Software Testing Framework
J2EE Application Development
Credit to Eclipse Documentation
Introduction to JUnit CS 4501 / 6501 Software Testing
Chapter 7 –Implementation Issues
Testing Acknowledgement: Original slides by Jory Denny.
John D. McGregor Module 6 Session 1 More Design
CMPE212 – Reminders Assignment 3 due next Friday.
John D. McGregor C15 – Variation in architecture
Principles of Object Oriented Programming
Presentation transcript:

CPSC 871 John D. McGregor Module 8 Session 2 JUnit

Test mechanism Due to its dynamic nature Java provides powerful facilities for examining code. JUnit was developed in the 1990’s as a reusable test framework that took advantage of that dynamic aspect to automatically assemble a set of test cases from a set of methods. Any method name that includes “test” is assumed to be a test case and is run by the framework. This has been sufficiently successful that there are now other _Unit implementations for other languages.

Test code In the next few slides we look at the PuckSupplyTest.java file from the BricklesProject. before the method definition insures that the method is run just before each method. Notice that several classes have to be instantiated in-order to test this one class. This is one of those situations in which writing the test cases early can inform about bad public void setUp() throws Exception { System.out.println("In test setup"); bv = new BricklesView(); ag = new BricklesGame(bv); pf = new PlayingField(ag); }

Test code - 2 The annotation before this method signals that the method is a test case. In this test case an instance of the PuckSupply class is created from scratch and then in the last line is queried to see if it contains the specified number of pucks. The assertTrue method at the end of the test case is part of the Junit test framework. It returns true/false depending on whether the “numberLeft” method returns public void testNumberLeft() { PuckSupply ps = new PuckSupply(pf); assertTrue(ps.numberLeft()==3); }

Test code - 3 From the AllTests.java class here is a way to create a single class that will execute a number test classes each with an arbitrary number of test cases. package bricklesPackage; import org.junit.runner.RunWith; import org.junit.runners.Suite; import --- Suite.class is from the Junit PuckSupplyTest.class }) --- all test classes are listed here public class AllTests { --- No need for any implementation }

Ant JUnit Task

Setup targets in Ant Build

Select targets

Run as a Junit configuration

Resulting display

Junit tutorial