Cell phones off Name signs out – congrats Sean! CSE 116 Introduction to Computer Science for Majors II1.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
MAHDI OMAR JUNIT TUTORIAL. CONTENTS Installation of Junit Eclipse support for Junit Using Junit exercise JUnit options Questions Links and Literature.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
TEST-DRIVEN DEVELOPMENT Lecture 3. Definition Test-driven development (development through testing) is a technique of programming, in which the unit tests.
First Day Of Class l Everything you need to succeed in your language class – in one place! URL:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
DAIMI(c) Henrik Bærbak Christensen1 JUnit A tool for test case management.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
By: Taylor Helsper.  Introduction  Test Driven Development  JUnit  Testing Private Methods  TDD Example  Conclusion.
By: Taylor Helsper.  Introduction  Test Driven Development  JUnit  TDD Example  Conclusion.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall NEW   NEW 1.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
CCS APPS CODE COVERAGE. CCS APPS Code Coverage Definition: –The amount of code within a program that is exercised Uses: –Important for discovering code.
Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.
StopPreviousNext Vicnet Internet training course Workbook 5 Introduction to Skype Easy English workbook March 2011.
Sadegh Aliakbary Sharif University of Technology Spring 2012.
Instructors begin using McGraw-Hill’s Homework Manager by creating a unique class Web site in the system. The Class Homepage becomes the entry point for.
MathXL ® for School Student Training Series Enrolling in Your MathXL ® for School Class & Setting Up Your Computer for MathXL ® for School.
Computer Science II 810:062 Section 01. How is CS I different from CS II? When you teach Java there are a series of decisions that have to be made…
ITBP 119 Algorithms and Problem Solving Section 2.1 Installing software Section 2.2 First Programs Section 2.3 Variables.
Welcome To Eclipse. Basic Concepts Workspace – directory where your projects are stored –Projects grouping of related works –Resources generic term to.
Creating and running a Java program. Eclipse Interactive Development Environment (IDE)  Eclipse is an Interactive Development Environment (IDE) for Java.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
Introduction to Computer Programming
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
A tool for test-driven development
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
Scalatest. 2 Test-Driven Development (TDD) TDD is a technique in which you write the tests before you write the code you want to test This seems backward,
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
JUnit A Unit Testing Framework for Java. The Objective Introduce JUnit as a tool for Unit Testing Provide information on how to: Install it Build a test.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
CIT 590 Intro to Programming Lecture 13. Some Eclipse shortcuts CTRL + SHIFT + F – format file (proper indentation etc). Please do this before you submit.
All the dSoftArk Tools Getting started!. Tools dSoftArk is a semi-realistic, agile, development project –Industrial strength software (programming, TDD,
Georgia Institute of Technology More on Creating Classes part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
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,
CS/ENGRD 2110 FALL 2013 Lecture 3: Fields, getters and setters, constructors, testing 1.
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
CSE 143 Lecture 14: testing.
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Lecture 5: Test-Driven Development Basics
Unit Testing.
Software Construction Lab 10 Unit Testing with JUnit
Dept of Computer Science University of Maryland College Park
Why should we test? How should we test?
Eclipse Navigation & Usage.
Executing Runtime Checks (For Comp401 and Comp410)
Software Engineering 1, CS 355 Unit Testing with JUnit
Some Tips for Using Eclipse
How to Run a Java Program
Test-Driven Development
CMPE212 – Reminders Assignment 2 due this Friday.
CS 240 – Advanced Programming Concepts
CSE 143 Lecture 5 More ArrayIntList:
JUnit Reading: various web pages
Test-Driven Development
Review of Previous Lesson
Junit Tests.
Presentation transcript:

Cell phones off Name signs out – congrats Sean! CSE 116 Introduction to Computer Science for Majors II1

Test Driven Development (TDD) write tests before code tests are executable requirements/specifications use unit testing tool to automate testing –test suite run at the click of a button –test results verified by testing tool We will use JUnit 4, installed for Eclipse CSE 116 Introduction to Computer Science for Majors II2

Basic structure of test For a given computation: –determine the expected value (the value which should be produced if the software is working correctly) –determine the actual value (the value which the software is actually computing) –compare the two: if they agree, the test passes if they disagree, the test fails CSE 116 Introduction to Computer Science for Majors II3

JUnit report If all tests pass, JUnit “green bars” If one or more tests fail, JUnit “red bars” –A report is given for each failed test –Click on failed test to navigate to the test code CSE 116 Introduction to Computer Science for Majors II4

Writing tests before code Think of test cases before writing code –make sure tests are a reflection of WHAT code should do –test must NOT be a reflection of HOW code solves the problem Let Eclipse generate stub code for application code that is needed for tests to compile CSE 116 Introduction to Computer Science for Majors II5

Our problem Develop a registration system for a course offering. Courses can enroll up to a maximum number of students. Students can add/drop/resign a course. Remember: this is an exercise to review some key CSE115 concepts, as well as introduce TDD CSE 116 Introduction to Computer Science for Majors II6

Write tests for a class that must have the following functionality: A CourseRoster holds Students. Student constructor takes first name and last name of student, as Strings. For example: Student("Jane","Smith") CourseRoster has methods: CourseRoster(int maxEnrollment) – creates a CourseRoster with the indicated maximum enrollment add(Student x) - ensures that x is in CourseRoster, as long as there is room in the course drop(Student x) - ensures that x is NOT in CourseRoster resign(Student x) - if x is in CourseRoster, marks them as resigned - if x is NOT in CourseRoster, does nothing enrollment() - returns the number of Students in CourseRoster resigns() - returns the number of Students in CourseRoster marked as resigned maxEnrollment() – returns the maximum number of spots available CSE 116 Introduction to Computer Science for Majors II7

On to Eclipse! CSE 116 Introduction to Computer Science for Majors II8

What we did with Eclipse today Created a new Java project Added two packages to the ‘src’ folder: –code  this is where the code for the application will reside –tests  this is where the tests for the application will reside We added a JUnit4 test case to the tests package CSE 116 Introduction to Computer Science for Majors II9

10 We created a new project, ‘FA10-CSE116-TDD’, and added two packages, ‘code’ and ‘tests’. The ‘code’ package will be for the application code, while the ‘tests’ package will be for our JUnit tests.

CSE 116 Introduction to Computer Science for Majors II11 Next we added a JUnit test case. JUnit tests. Make sure the test case (which is really just a Java class) is in the ‘tests’ package; give it a name (here ‘ClassRosterTests’.

CSE 116 Introduction to Computer Science for Majors II12 Let Eclipse add the JUnit4 library to the project’s build path.

CSE 116 Introduction to Computer Science for Majors II13 Eclipse generates a skeletal class definition for ‘ClassRosterTests’.

CSE 116 Introduction to Computer Science for Majors II14 Now we are ready to start writing our very first unit test. A unit test is written as a void method with an empty parameter list; the annotation identifies this as a test method to the JUnit tool.

Next steps? Next class we will show what the innards of the test method looks like. The basic idea is to exercise the code we are planning on writing, asking it to compute an answer for us, and comparing that to the known correct answer. Stay tuned! CSE 116 Introduction to Computer Science for Majors II15