Automatisk tests og Continuous delivery Med afsæt i Bitmagasin og Netarkiv projekterne.

Slides:



Advertisements
Similar presentations
JUnit Tutorial Hong Qing Yu Nov JUnit Tutorial The testing problems The framework of JUnit A case study JUnit tool Practices.
Advertisements

COSC 1P03 Data Structures and Abstraction 10.1 The List If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping.
Practice Session 5 Java: Packages Collection Classes Iterators Generics Design by Contract Test Driven Development JUnit.
Ics202 Data Structures. hh tail head (b) LinkedList head tail Element datum next 3 Integer Element datum next 1 Integer Element datum next 4 Integer.
Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian, Mike Ernst, and Kellen Donohue Section 4: Graphs and Testing.
J-Unit Framework.
Java Classes ISYS 350. Introduction to Classes A class is the blueprint for an object. – It describes a particular type of object. – It specifies the.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
1 ADT and Data Structure Example Generics / Parameterized Classes Using a Set Implementing a Set with an Array Example: SetADT interface Example: ArraySet.
Final Project of Information Retrieval and Extraction by d 吳蕙如.
CS 2110 Software Design Principles II Based on slides originally by Juan Altmayer Pizzorno port25.com.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
Stacks.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
Verify your data entry You could use data types and field properties for adding any validation on your date: EX: Data type: number : allow the user to.
Intoduction to Unit Testing Using JUnit to structure Unit Testing SE-2030 Dr. Rob Hasker 1 Based on material by Dr. Mark L. Hornick.
Examples of Recursion Data Structures in Java with JUnit ©Rick Mercer.
1 Intro to Java Week 12 (Slides courtesy of Charatan & Kans, chapter 8)
File Input and Output in C++. Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) Keyboard Screen executing program input data.
Grouping objects Introduction to collections 5.0.
1 C Programming Week 2 Variables, flow control and the Debugger.
Java Classes ISYS 350. Introduction to Classes A class is the blueprint for an object. – It describes a particular type of object. – It specifies the.
Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.
Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);
ArrayList Class An ArrayList is an object that contains a sequence of elements that are ordered by position. An ArrayList is an object that contains a.
1 Command Processor V Saving Changes. Command Processor We need to be able to save changes to the database that result from user actions. Download example.
Inheritance (Part 2) Notes Chapter KomondorBloodHound PureBreedMix Dog Object Dog extends Object PureBreed extends Dog Komondor extends PureBreed.
(c) University of Washington16-1 CSC 143 Java Linked Lists Reading: Ch. 20.
CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010.
JUnit Don Braffitt Updated: 10-Jun-2011.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
© David Kirk/NVIDIA and Wen-mei W. Hwu University of Illinois, CS/EE 217 GPU Architecture and Parallel Programming Lecture 15: Atomic Operations.
CS 367 Introduction to Data Structures Lecture 2 Audio for Lecture 1 is available Homework 1 due Friday, September 18.
Problem 1 Bank.  Manage customers’ bank account using the following operations: Create a new account given a customer’s name and initial account. Deposit.
1 Data Structures CSCI 132, Spring 2014 Lecture 34 Analyzing Hash Tables.
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.
GROUPING OBJECTS CITS1001. Lecture outline The ArrayList collection Process all items: the for-each loop 2.
Davisware GlobalEdge 2008 Payroll Main Menu Time Entry and Payroll Processing.
Introduction to Eclipse Programming with an Integrated Development Environment.
Grouping objects Introduction to collections 5.0.
Justin Bare and Deric Pang with material from Erin Peach, Nick Carney, Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section.
Object-Oriented Programming (Java) Review Unit 1 Class Design Basic Console I/O StringTokenizer Exception UML class diagram.
Scanner as an iterator Several classes in the Java standard class library Are iterators Actually, the Scanner class is an iterator  The hasNext returns.
15 – PHP(5) Informatics Department Parahyangan Catholic University.
By: “Ivan” Presented by: Chris Niznik. Introduction How to set up page numbers Use chapter numbers Add date Add line numbers.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Consistency Checking And RUCIO Progress Update Sarah Williams Indiana University ADC Weekly Meeting,
Reasoning and Design (and Assertions). How to Design Your Code The hard way: Just start coding. When something doesn’t work, code some more! The easier.
Import existing part with drawing
An Array-Based Implementation of the ADT List
Excel Tutorial 8 Developing an Excel Application
Dept of Computer Science University of Maryland College Park
Michael Eng Mentors: Mark Pumphrey, Greg Cordero
Error Handling Summary of the next few pages: Error Handling Cursors.
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
CS 190 Lecture Notes: Exception Handling
CS 190 Lecture Notes: Exception Handling
Copyright ©2012 by Pearson Education, Inc. All rights reserved
COMPUTER 2430 Object Oriented Programming and Data Structures I
Building Java Programs
Introduction to JUnit CS 4501 / 6501 Software Testing
Building Java Programs
COMPUTER 2430 Object Oriented Programming and Data Structures I
Building Java Programs
Building Java Programs
CSE 143 Lecture 5 More ArrayIntList:
Objects with ArrayLists as Attributes
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Presentation transcript:

Automatisk tests og Continuous delivery Med afsæt i Bitmagasin og Netarkiv projekterne

Emnerne • Design for testing. • Test design og best practices. • Unit tests vs. system tests. • Continuous integration. • Continuous delivery.

Design for test • Lettere tests • Test er initielle bruger af test • Bedre design – Blackbox test -> præcise API’er. – Seperation af hensyn – Modulart design Eksempler • Teori og Praksis

Kontrakt -> test kriterier public class WorldHelper { public void update() { ….. }

Kontrakt -> test kriterier public class WorldHelper { public void improveWorld() { …..

Kontrakt -> test kriterier public class WorldHelper { public void improveWorld(int flowers2Add) { world.flowers.add(7); …..

Dependency injection public class WorldHelper { private WorldImprover improver; public void improveWorld() { improver.improve(world); ….. } public void setImprover(WorldImprover improver) { this.improver = improver;

Dependency injection public class WorldHelper { private final WorldImprover improver; public WorldHelper (WorldImprover improver) { this.improver = improver; } public void improveWorld() { improver.improve(world); ….. }

Singleton, hrrrmmm public class WorldHelper { public WorldHelper () { world = World.getInstance(); } public void improveWorld() { world.improve(); }

Minimer sideeffekt public class WorldHelper { public void improveWorld(World world) { improver.improve(world); }

Minimer sideeffekt public class WorldHelper { public World improveWorld(World oldWorld) { return improver.improve(world); }

Små, præcise metoder public World improveWorld() { Date beforeTest = new Date(Calendar.getInstance().getTimeInMillis()); assertTrue("The database should be empty to begin with.", cache.isEmpty()); // try handling output from ChecksumJob. File csFile = makeTemporaryChecksumFile1(); cache.addChecksumInformation(csFile, Replica.getReplicaFromId("ONE")); // try handling output from FilelistJob. File flFile = makeTemporaryFilelistFile(); cache.addFileListInformation(flFile, Replica.getReplicaFromId("TWO")); Date dbDate = cache.getDateOfLastMissingFilesUpdate( Replica.getReplicaFromId("TWO")); Date afterInsert = new Date(Calendar.getInstance().getTimeInMillis()); // Assert that the time of insert is between the start of this test // and now. assertTrue("The last missing file update for replica '" + Replica.getReplicaFromId("ONE") + "' should be after " + "the test was begun. Thus '" + DateFormat.getDateInstance().format(dbDate) + "' should be after '" + DateFormat.getDateInstance().format(beforeTest) + "'.", dbDate.after(beforeTest)); assertTrue("The last missing file update for replica '" + Replica.getReplicaFromId("ONE") + "' should be before " + "the current time. Thus '" + DateFormat.getDateInstance().format(dbDate) + "' should be before '" + DateFormat.getDateInstance().format(afterInsert) + "'.", dbDate.before(afterInsert)); // Check that getDateOfLastWrongFilesUpdate gives a date between // the start of this test and now. dbDate = cache.getDateOfLastWrongFilesUpdate(Replica.getReplicaFromId("ONE")); assertTrue("The last missing file update for replica '" + Replica.getReplicaFromId("ONE") + "' should be after " + "the test was begun. Thus '" + DateFormat.getDateInstance().format(dbDate) + "' should be after '" + DateFormat.getDateInstance().format(beforeTest) + "'.", dbDate.after(beforeTest)); assertTrue("The last missing file update for replica '" + Replica.getReplicaFromId("ONE") + "' should be before " + "the current time. Thus '" + DateFormat.getDateInstance().format(dbDate) + "' should be before '" + DateFormat.getDateInstance().format(afterInsert) + "'.", dbDate.before(afterInsert)); // retrieve empty file and set all files in replica 'THREE' to missing File fl2File = makeTemporaryEmptyFilelistFile(); cache.addFileListInformation(fl2File, Replica.getReplicaFromId("THREE")); flFile, // check that all files are unknown for the uninitialised replica. long files = FileUtils.countLines(csFile); System.out.println(cache.getMissingFilesInLastUpdate( Replica.getReplicaFromId("THREE"))); System.out.println(FileUtils.readListFromFile(csFile)); assertEquals("All the files for replica 'THREE' should be missing.", files, cache.getNumberOfMissingFilesInLastUpdate( Replica.getReplicaFromId("THREE"))); // check that the getMissingFilesInLastUpdate works appropriately. List misFiles = IteratorUtils.toList(cache.getMissingFilesInLastUpdate( Replica.getReplicaFromId("THREE")).iterator()); List allFilenames = new ArrayList (); for(String entry : FileUtils.readListFromFile(csFile)) { String[] e = entry.split("##"); allFilenames.add(e[0]); } assertEquals("All the files should be missing for replica 'THREE': " + misFiles + " == " + allFilenames, misFiles, allFilenames); // adding the checksum for the other replicas. cache.addChecksumInformation(csFile, Replica.getReplicaFromId("TWO")); // check that when a replica is given wrong checksums it will be // found by the update method. assertEquals("Replica 'THREE' has not been assigned checksums yet." + " Therefore not corrupt files yet!", 0, cache.getNumberOfWrongFilesInLastUpdate(Replica.getReplicaFromId("THREE"))); assertEquals("No files has been assigned to replica 'THREE' yet.", 0, cache.getNumberOfFiles(Replica.getReplicaFromId("THREE"))); File csFile2 = makeTemporaryChecksumFile2(); cache.addChecksumInformation(csFile2, Replica.getReplicaFromId("THREE")); assertEquals("All the files in Replica 'THREE' has been assigned " + "checksums, but not checksum update has been run yet. " + "Therefore no corrupt files yet!", 0, cache.getNumberOfWrongFilesInLastUpdate(Replica.getReplicaFromId("THREE"))); assertEquals("Entries for replica 'THREE' has should be assigned.", FileUtils.countLines(csFile2), cache.getNumberOfFiles(Replica.getReplicaFromId("THREE"))); cache.updateChecksumStatus(); assertEquals("After update all the entries for replica 'THREE', " + "they should all be set to 'CORRUPT'!", FileUtils.countLines(csFile2), cache.getNumberOfWrongFilesInLastUpdate(Replica.getReplicaFromId("THREE"))); assertEquals("All the entries for replica 'THREE' is all corrupt, " + "but they should still be counted.", FileUtils.countLines(csFile2), cache.getNumberOfFiles(Replica.getReplicaFromId("THREE"))); // Check that all files are wrong for replica 'THREE' List wrongFiles = IteratorUtils.toList(cache.getWrongFilesInLastUpdate(Replica.getReplicaFromId("THREE")).iterator()); assertEquals("All the files should be wrong for replica 'THREE': " + wrongFiles + " == " + allFilenames, wrongFiles, allFilenames); // check that a file can become missing, after it was ok, but still be ok! cache.addFileListInformation(

Små, præcise metoder public World improveWorld() { stopWars(world); waterDeserts(world); bringBackMammuts(world); …. } protected void stopWars(World world) {

Test design

Meget af det samme • Små, præcise tests • Robuste tests • Generaliser

Unit test vs. System test Unit test • Hurtige • Automatiske • Fail-pass resultat • Kodenære • Kode er testspec • Kræver udviklingsmiljø • Konsistent System test • Langsomme • Manuelle • Brugerkontrolleret • Testrapport • Del af dokumentationen som testspec • Kræver testmiljø • Explorativ testing