Section 3 Graphs & Testing

Slides:



Advertisements
Similar presentations
Practice Session 5 Java: Packages Collection Classes Iterators Generics Design by Contract Test Driven Development JUnit.
Advertisements

Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, and Kellen Donohue Section 4: Graphs and Testing.
MAHDI OMAR JUNIT TUTORIAL. CONTENTS Installation of Junit Eclipse support for Junit Using Junit exercise JUnit options Questions Links and Literature.
try { Assert(Life. Real); Assert(Life
Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 5: HW6 and Interfaces.
JUnit Automated Software Testing Framework Paul Ammann & Jeff Offutt Thanks in part to Aynur Abdurazik.
Objectives: Test Options JUnit Testing Framework TestRunners Test Cases and Test Suites Test Fixtures JUnit.
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.
14-Jul-15 JUnit 4. Comparing JUnit 3 to JUnit 4 All the old assertXXX methods are the same Most things are about equally easy JUnit 4 makes it easier.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
© Dr. A. Williams, Fall Present Software Quality Assurance – JUnit Lab 1 JUnit A unit test framework for Java –Authors: Erich Gamma, Kent Beck Objective:
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.
Computer Science and Engineering College of Engineering The Ohio State University JUnit The credit for these slides goes to Professor Paul Sivilotti at.
Testing in Extreme Programming
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Introduction to Testing 1. Testing  testing code is a vital part of the development process  the goal of testing is to find defects in your code  Program.
JUnit test and Project 3 simulation. 2 JUnit The testing problems The framework of JUnit A case study Acknowledgement: using some materials from JUNIT.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
Introduction to JUnit 3.8 SEG 3203 Winter ‘07 Prepared By Samia Niamatullah.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
A programmer’s wife tells him, “Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen.” The programmer.
JUnit Don Braffitt Updated: 10-Jun-2011.
1 CSE 331 Unit Testing with JUnit slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
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,
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
CSE 143 Lecture 4 More ArrayIntList : Pre/postconditions; exceptions; testing reading: slides created by Marty Stepp and Hélène Martin
CS-2852 Data Structures LECTURE 7B Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
SLIDES ADAPTED FROM ALEX MARIAKAKIS, WITH MATERIAL FROM KRYSTA YOUSOUFIAN, MIKE ERNST, KELLEN DONOHUE Section 5: HW6 and Interfaces Justin Bare and Deric.
Unit Testing. F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have?
SE 433/333 Software Testing & Quality Assurance Dennis Mumaugh, Instructor Office: CDM, Room 428 Office Hours: Tuesday, 4:00 –
CMSC 202, Version 5/02 1 Trees. CMSC 202, Version 5/02 2 Tree Basics 1.A tree is a set of nodes. 2.A tree may be empty (i.e., contain no nodes). 3.If.
Justin Bare and Deric Pang with material from Erin Peach, Nick Carney, Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section.
Slides with material from Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 3: HW4, ADTs, and more.
Unit Testing in Eclipse Presented by David Eisler 08/09/2014.
A programmer’s roommate tells him, “Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen.” The programmer.
CSE 143 Lecture 14: testing.
Section 4: Graphs and Testing
CompSci 280 S Introduction to Software Development
Unit Testing.
Software Construction Lab 10 Unit Testing with JUnit
They both stop working when you open Windows!
Don Braffitt Updated: 26-Mar-2013
Unit Testing with JUnit
JUnit Automated Software Testing Framework
Introduction to JUnit CS 4501 / 6501 Software Testing
This presentation is created for the course COP4331 at UCF
COMP 103 Testing with JUnit 2016-T2 extras
Week 15 – Monday CS221.
Junit with.
Section 5: HW6 and Interfaces
JUnit Automated Software Testing Framework
Section 5: HW6 and Interfaces
Introduction to JUnit CS 4501 / 6501 Software Testing
Trees CMSC 202, Version 5/02.
CMSC 202 Trees.
The programmer returns with 12 loaves of bread.
Testing Acknowledgement: Original slides by Jory Denny.
Section 4: Interfaces Parsing Data and
Section 5: HW6 and Interfaces
Testing 24-Feb-19.
Section 4: Graphs and Testing
Warmup ["hip","hip"] = Hip Hip Array! ???.
CSE 143 Lecture 5 More ArrayIntList:
Section 5: HW6 and Interfaces
JUnit Reading: various web pages
Testing Slides adopted from John Jannotti, Brown University
Principles of Object Oriented Programming
Presentation transcript:

Section 3 Graphs & Testing Slides by Andrew and Anny with material from Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue

Agenda Graphs Testing

Graph = collection of nodes (vertices) and edges B Nodes: states or objects within the graph Edges: connection between two nodes C D E my friend: I can't figure out how to store nodes in my graph me, an intellectual: you can't figure how to store *vertices* in your graph

Some examples Linked Lists Binary Trees Luke A B C Leia Droids C3PO R2-D2

Directed graph vs Undirected graph = edges have a source and destination Arrows as edges Parent and child nodes related by an edge

Directed graph vs Undirected graph What are some examples? A B C D

Directed graph vs Undirected graph Build systems Facebook friends Course prerequisites Map of U-District Restaurants CSE311 CSE332 John Sally

Cyclic vs Acyclic Why do we need them? Special type of graphs: B C B C A Special type of graphs: Directed Acyclic Graphs (DAGs) Why do we need them?

Worksheet

What is Testing? Implementation tests Specification tests When to do which one?

Implementation vs. Specification Implementation tests: How you decide to implement the object. See if each component (unit) is working properly. Specification tests: Testing your API against the specifications. Usually larger than unit tests.

Black box vs. Clear box Black box: Clear box: Written with knowledge of only the Specification. Clear box: Written with full knowledge of an implementation.

Worksheet

A JUnit test class (Demo) A method with @Test is a JUnit test. All @Test methods run when JUnit runs. import org.junit.*; import static org.junit.Assert.*; public class TestSuite { @Test public void Test1() { … }

Using JUnit assertions Verifies that a value matches expectations assertEquals(42, meaningOfLife()); assertTrue(list.isEmpty()); If the assert fails: Test immediately terminates. Other tests in the test class still run. Results show information about failed tests.

Using JUnit assertions Case for failure assertTrue(test) the boolean test is false assertFalse(test) the boolean test is true assertEquals(expected, actual) the values are not equal assertSame(expected, actual) the values are not the same (by ==) assertNotSame(expected, actual) the values are the same (by ==) assertNull(value) the given value is not null assertNotNull(value) the given value is null And others: http://www.junit.org/apidocs/org/junit/Assert.html Each method can also be passed a string to display if it fails: assertEquals("message", expected, actual)

Checking for exceptions (Demo) Verify that a method throws an exception when it should: Passes only if specified exception is thrown Only time it’s OK to write a test without a form of asserts @Test(expected=IndexOutOfBoundsException.class) public void testGetEmptyList() { List<String> list = new ArrayList<String>(); list.get(0); }

Setup and teardown @Before public void name() { ... } @After Methods to run before/after each test case method is called: @Before public void name() { ... } @After Methods to run once before/after the entire test class runs: @BeforeClass public static void name() { ... } @AfterClass

Setup and teardown public class Example { List<String> empty; @Before public void initialize() { empty = new ArrayList<>(); } @Test public void size() {...} public void remove() {...}

Ground rules 1. Don’t Repeat Yourself 2. Be Descriptive Use constants and helper methods 2. Be Descriptive Take advantage of message, expected, and actual values 3. Keep Tests Small Isolate bugs one at a time; failing assertion halts test 4. Be Thorough Test big, small, boundaries, exceptions, errors

Expensive checkReps() Before your final commit, remove the checking of expensive parts of your checkRep or the checking of your checkRep entirely Example: boolean flag and structure your checkRep as so: private void checkRep() { cheap-stuff if(DEBUG_FLAG) { // or can have this for entire checkRep expensive-stuff } ...

Summary Demo will be uploaded JUnit documentation online Reminder: you can generate the JavaDoc API for your code Located under `build/docs/javadoc` in project folder. IntelliJ Gradle Instructions in the Editing/Compiling Handout. Run the Javadoc command