Testing. Technion Institute of Technology Author: Assaf Israel. Author: Assaf Israel - Technion
|
|
- Mervin Warren
- 5 years ago
- Views:
Transcription
1 Testing Technion Institute of Technology Author: Assaf Israel
2 Why test? Programming is incremental by nature We want to verify we haven t broken anything Tests not only examine the code s functionality but also its Ease of use API Boilerplate & setup Error path behavior Reveals coherency issues Good tests forces the production code to be modular (decoupled) Tests are the usage example of our code and are an excellent source for documentation 2
3 Testable Code Good Code Tests are usually the first time outside code will use your production code! Is the production code hard to test? Do you write LOC before you reach the assert line? Is it difficult to assert the desired behavior? Do you find it hard isolating the tested feature? Are you not even sure what you should be asserting? Is the production code hard to use? Is object creation hard and complex? Are methods cryptic with a lot of parameters? How does your production code handle usage errors? Have you been surprised by a method behavior? 3
4 Test types Our focus today Unit Tests Test a single element of the system A single element does not necessarily imply a single class Integration Tests Verify that a few units can work together and are wired up correctly End-to-End Tests Test the complete flow of interactions throughout the system Acceptance / Business logic Tests Answers the question: Did we build what we wanted? 4
5 Test types 5
6 Testing Framework Wish list Better Asserts: Validating results Vs. expectations assert(sqrt(4) == 2) Vs. assertequal(2,sqrt(4)) assert(x!= null) Vs. assertnotnull(x) Clear indication of Success / Failure Meaningful message upon failure Ease of use Should be easy to add new Tests Aggregate tests together into Test Cases / Tests Suites Continue with other tests even if a test fails / throws an exception No duplication of initialization code of tested objects Side effects should not influence other tests 6
7 JUnit A unit testing framework for Java A Test is a Method A Test Case is a class which includes tests methods Aggregates tests for a single tested unit A Test Suite is a collection of Test Cases / Test Suites (or both) Used to create a hierarchy of tests 7
8 JUnit 4.0 A step up from JUnit 3.0 New Assertions methods in org.junit.assert.* No need to extend from junit.framework.testcase No need to prefix test methods with test Test methods are runs once before first test Setting up the stubs objects / DB runs once after the last test Closing DB method runs before every test Preparing data Could be used for advanced method runs after every test Resetting stubs / cleaning data 8
9 JUnit test case - Running all methods annotated with A Test Case Class load Static C C tor C tor C tor @After* 9
10 JUnit life-cycle - Example Expensive and global resources can be initialized and destroyed before/after all tests public class DbTests { static DatabaseConnection public static void login() { database public void testsomething() public void testsomethingelse() public static void logout() { database.logout(); 10
11 JUnit life-cycle - Example Local resources should be initialized and cleaned before/after every test public class DbTests { File public void createoutputfile() { output = new public void testsomething() public void testsomethingelse() public void deleteoutputfile() { output.delete(); 11
12 JUnit Example Assuming we want to test a new Stack interface implementation import org.junit.assert; import org.junit.test; public class StackTestCase { Name is testing public void peekreturnsthelastpusheditem() { Stack<String> s = new ArrayListStack<>(); s.push("first-item"); s.push("last-item"); Assert.assertEquals("LAST-ITEM", s.peek()); Expectation Initialization Result org.junit.comparisonfailure: expected:<[last]-item> but was:<[first]-item> Smart Asserts: assertnotequal, asserttrue, assertsame, assertnotnull, assertarrayequal, etc. 12
13 Ideal Test A recipe for a good public void testshouldnameexplicitlystatesexpectation() { (1) Initialize collaborators (2) Initialize object under test (3) Exercise behavior (4) Assert outputs Ideally: (1) will be very short (2) will be simply a new MyClass() (3) will be a single method invocation (4) will be a single assert Of course this ideal cannot always be achieved But if you can t, you should always ask yourselves why? 13
14 Test names It should be easy pin-pointing the problem from the test without even looking at its code Consider the following public void additemtest() { Product p = new Product(); p.setavailable(false); ShoppingCart cart = new ShoppingCart(); cart.additem(p); assertequals(0, p.numitems()); How about additemwithoutofstockproduct? Describes the method and the parameter Bad name. Specifies the name of the invoked method but not describes the desired behavior Still not a good name does not describes the desired behavior 14
15 Test names It should be trivial understanding what is the expected behavior from the name alone We do not need to mention the name of the invoked public void donotaddoutofstockitem() { Product p = new Product(); p.setavailable(false); ShoppingCart cart = new ShoppingCart(); cart.additem(p); assertequals(0, p.numitems()); Good rule of thumb: the test name should include an explicit expectation Use verbs such as should, does, returns, throws, etc. 15
16 JUnit Exceptions A test that throws an exception will fail. So how do make sure a code throws an exception when it should? We would like to verify 3 things: The right exception has been thrown The exception contains the right message The right line has thrown the exception 16
17 JUnit Exceptions The hard way Use the try/catch public void badencodeargument() { Encoder encoder = new Encoder( UTF-8 ); try { encoder.encode(null); fail( Exception should have been thrown ); catch (NullPointerException e) { assertequals( Text should not be null,e.getmessage()); Verifies our 3 wishes Easy to forget the fail resulting in a test that never fails Quite long and verbose Test code is just as important as our regular code! We want to minimize code duplication and boilerplate. 17 Based on
18 JUnit Exceptions The easy way (JUnit 4.0) expected value = IllegalArgumentException.class) public void badencodeargument() { Encoder encoder = new Encoder( UTF-8 ); encoder.encode(null); Can t check the exception message Can t verify which line has thrown the exception Very short Can be good enough in many cases, but we can do better 18 Based on
19 JUnit Exceptions The smart way (JUnit 4.7) annotation and public ExpectedException thrown = public void badencodeargument() { Encoder encoder = new Encoder( UTF-8 ); thrown.expect(nullpointerexception.class); thrown.expectmessage( Text should not be null ); encoder.encode(null); Verifies our 3 wishes Still quite short JUnit Rules offers a few additional candies 19 Based on
20 JUnit - Timeout We want to verify that our code finishes in the allotted public void testtimeout() { final boolean[] done = new boolean[] { false ; new Timer().schedule(new TimerTask() public void run() { foo(); done[0] = true; Test will fail after 10 milliseconds., 0); Thread.sleep(10); if (done[0] == false) fail( Failed to run in the allotted time"); This is criminally verbose Surely, there is a simpler way 20
21 JUnit - Timeout In JUnit 4.0 Use the timeout annotation = 10) public void testtimeout() { // Tested code Test will fail after 10 milliseconds. Global timeouts (JUnit public MethodRule globaltimeout = new public void test1() { // Tested public void test2() { // Tested code 21
22 JUnit Ignoring tests You can ignore tests using annotation Test will not run, but will still be visible in the test reports Commented out tests will usually be forgotten about Won t be deleted and possibly will not be fixed Ignored tests are easily visible in the output window Make sure you disable tests temporarily Bad tests should either be deleted or fixed Ask yourself why are you ignoring the test in the first place? 22
23 JUnit - Running Textual runner Used mainly in command line environments (Scripts, Maven, Ant, CI) org.junit.runner.junitcore.runclasses(testcase1.class,...); IDE Support To run several TestCase1.class, TestCase2.class, subpackage.alltests.class, ) public class AllTests { 23
24 JUnit Source code Organization Option 1: Test class in same folder as subject A single hierarchy of folders Locality Option 2: Keep tests in the mirrored directory structure of source location A duplicated hierarchy of folders Easy to find all tests Easy to separate source code from its tests Easier bytecode separation 24
25 Testing Leveraging OOP Tests are classes too! Can use inheritance to our advantage Use Abstract Test classes against abstract classes / interfaces Classes Tests Class A ATest B C BTest CTest 25
26 Testing Leveraging OOP public abstract class Stack<T> { public void push(t element); public int size(); public class ArrayStack<T> extends Stack<T> { // implementation code public class LinkedListStackStack<T> extends Stack<T> { // implementation code 26
27 Testing Leveraging OOP public abstract class StackTest { private final Stack<Object> stack; protected StackTest(Stack<Object> stack) { this.stack = public void sizeisoneafteronepush() { stack.push(new Object()); Assert.assertEquals(1, stack.size()); 27
28 Testing Leveraging OOP Extend abstract TC to initialize the concrete test subjects public class ArrayStackTest extends StackTest { public ArrayStackTest() { super(new ArrayStack<Object>()); // specific ArrayStack tests public class LinkedListStackTest extends StackTest { public LinkedListStackTest() { super(new LinkedListStack<Object>()); // specific LinkedListStackTest tests 28
29 Testing Order (or lack thereof) Do not assume order between tests There s no order guaranties in TestCases There is one in TestSuites Avoid side effects in tests public class StackTest { private static Stack<Object> s = new public void pushfirstandchecksize() { s.push(new Object()); public void pushsecondandchecksize() { s.push(new Object()); assertequals(2,s.size()); 29
30 Testing Resource Management Do not load data from hard-coded locations on a file public void setup () { InputStream inp = FileInputStream("C:\\TestData\\dataSet1.dat"); Use Class.getResource() or public void setup () { InputStream inp = getclass().getresourceasstream("dataset1.dat"); Will search the file relatively to the Test Case.class file Maven will automatically create a src & test resource folders 30
31 Unit Testing: What to Test It is not practical to test everything: State space > 2 #arguments+#members Not always practical Loops in the code State space is infinite / Halting Problem E2E and Acceptance tests will cover the state space quite well Contracts (later in the course) Cover as much of the code as possible, but be smart about it Extensiveness of the test should be proportional to the complexity of the impl. of the tested method If m2() calls m1(), no need to duplicate m1() tests for m2() But, for each variation in the flow (usually an if()) you should have a corresponding test that exercises it Always test public methods Should you test package-private and protected methods as well? Private methods usage is important only in the context public methods If you find yourself wanting to test a private method, you should rethink your design, (e.g., extract the private method to a helper class) 31
32 Unit Testing: Quality Cover code usage Check common usage errors / edge cases: nulls empty strings zeros empty lists single-item lists uninitialized objects bad configurations Exception handling Code Coverage Function, Statement, Branch, Decision coverage Monitor using external Code Coverage tools (e.g. EclEmma) 32
33 Code Coverage - EclEmma 33
34 Code Coverage Code coverage is correlated with good testing, but does not equate it You can achieve very high coverage with bad tests (e.g., testing without asserts) You can write great tests with low coverage 100% coverage may look pretty, but is pointless You should always suspect tests that were written solely for achieving high coverage You can use code coverage to Spartanize your code e.g., branches that are never taken may be dead code 34
35 Testing Do s & Don ts Always place shortest, simplest tests first in a TestCase or in a TestSuite You should always make sure the simplest cases work before you carry on to the complicated ones Prefer lots of short tests instead of a few long ones Every test should test a single behavior Speed up discovery-to-fix cycle Testing code should be simpler than the subject code Complicated test usually implies complicated production code usage Tests are the code usage examples Do not put if() statements in your tests. Loops are quite rare. 35
36 Testing Do s & Don ts Always make sure you start Green before you start coding. Unless working in TDD Run tests as often as possible The earlier you detect the bug the sooner you solve it and the easier it becomes Regression testing Make sure new additions don t break existing code When you work on a bug, write a test case first Your work is done when the test case succeeds If you write the test after the bug is fixed, you cannot know if the test succeeded in reproducing the bug 36
37 Testing Do s & Don ts When you change the subject class, add tests Testing is meant to improve the quality of the code Do not write bad code to pass tests!! Although possible in TDD Do not write bad tests to pass tests!! (Make sure a test can fail) Do not simply change a private method into a public one so you can test it It will probably be wiser to extract the method into a new class, and then make it public/package Hard to test? Re-think the design! 37
Agenda. JUnit JaCoCo Project. CSE 4321, Jeff Lei, UTA
Agenda JUnit JaCoCo Project 1 JUnit Introduction A JUnit Example Major APIs Practical Tips 2 Unit Testing Test individual units of source code in isolation Procedures, functions, methods, and classes Engineers
More informationTest Isolation and Mocking
Test Isolation and Mocking Technion Institute of Technology 236700 1 Author: Assaf Israel Unit Testing: Isolation The bigger the test subject the harder it is to understand the reason of a bug from a test
More informationTest automation / JUnit. Building automatically repeatable test suites
Test automation / JUnit Building automatically repeatable test suites Test automation n Test automation is software that automates any aspect of testing n Generating test inputs and expected results n
More informationTest automation Test automation / JUnit
Test automation Test automation / JUnit Building automatically repeatable test suites Test automation is software that automates any aspect of testing Generating test inputs and expected results Running
More informationSection 4: Graphs and Testing. Slides by Erin Peach and Nick Carney
Section 4: Graphs and Testing Slides by Erin Peach and Nick Carney with material from Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue AGENDA Graphs JUnit Testing Test Script
More informationTest-Driven Development JUnit
Test-Driven Development JUnit Click to edit Master EECS text 2311 styles - Software Development Project Second level Third level Fourth level Fifth level Wednesday, January 18, 2017 1 Simulator submission
More informationTools for Unit Test - JUnit
Tools for Unit Test - JUnit Conrad Hughes School of Informatics Slides thanks to Stuart Anderson 15 January 2010 Software Testing: Lecture 2 1 JUnit JUnit is a framework for writing tests Written by Erich
More informationChapter 15. Software Testing The assert Statement
177 Chapter 15 Software Testing We know that a clean compile does not imply that a program will work correctly. We can detect errors in our code as we interact with the executing program. The process of
More informationTools for Unit Test JUnit
Tools for Unit Test JUnit Stuart Anderson JUnit is a framework for writing tests JUnit 1 Written by Erich Gamma (Design Patterns) and Kent Beck (extreme Programming) JUnit uses Java s reflection capabilities
More informationxtreme Programming (summary of Kent Beck s XP book) Stefan Resmerita, WS2015
xtreme Programming (summary of Kent Beck s XP book) 1 Contents The software development problem The XP solution The JUnit testing framework 2 The Software Development Problem 3 Risk Examples delivery schedule
More informationEECS 4313 Software Engineering Testing
EECS 4313 Software Engineering Testing Topic 03: Test automation / JUnit - Building automatically repeatable test suites Zhen Ming (Jack) Jiang Acknowledgement Some slides are from Prof. Alex Orso Relevant
More informationTest-Driven Development JUnit
Test-Driven Development JUnit Click to edit Master EECS text 2311 styles - Software Development Project Second level Third level Fourth level Fifth level Wednesday, January 24, 2018 1 Unit Testing Testing
More informationWhite-box testing. Software Reliability and Testing - Barbara Russo SERG - Laboratory of Empirical Software Engineering.
White-box testing Software Reliability and Testing - Barbara Russo SERG - Laboratory of Empirical Software Engineering Barbara Russo 1 White-box testing White-box testing is a verification technique that
More informationJUnit in EDA Introduction. 2 JUnit 4.3
Lunds tekniska högskola Datavetenskap, Nov 25, 2010 Görel Hedin EDA260 Programvaruutveckling i grupp projekt Labb 3 (Test First): Bakgrundsmaterial JUnit in EDA260 1 Introduction The JUnit framework is
More informationTest suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (testing whatever occurs to you at
JUnit Test suites Obviously you have to test your code to get it working in the first place You can do ad hoc testing (testing whatever occurs to you at the moment), or You can build a test suite (a thorough
More informationAgile Software Development. Lecture 7: Software Testing
Agile Software Development Lecture 7: Software Testing Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Slides are a modified version of the slides by Prof. Kenneth M. Anderson Outline Testing Terminology Types
More informationSoftware Development Tools. COMP220/COMP285 Sebastian Coope Eclipse and JUnit: Creating and running a JUnit test case
Software Development Tools COMP220/COMP285 Sebastian Coope Eclipse and JUnit: Creating and running a JUnit test case These slides are mainly based on Java Development with Eclipse D.Gallardo et al., Manning
More informationUNIT TESTING. Krysta Yousoufian CSE 331 Section April 19, With material from Marty Stepp, David Notkin, and The Pragmatic Programmer
UNIT TESTING Krysta Yousoufian CSE 331 Section April 19, 2012 With material from Marty Stepp, David Notkin, and The Pragmatic Programmer JUnit Semantics How to write a technically correct JUnit test A
More informationObject Oriented Software Design - I
Object Oriented Software Design - I Unit Testing Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa November 28, 2011 G. Lipari (Scuola Superiore Sant Anna) Unit Testing November
More informationTesting. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?
Testing CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Testing Feb. 15, 2007 Some slides adapted from FSE 98 Tutorial by Michal Young and Mauro Pezze Execute program on sample input
More informationUnit Testing. CS 240 Advanced Programming Concepts
Unit Testing CS 240 Advanced Programming Concepts F-22 Raptor Fighter 2 F-22 Raptor Fighter Manufactured by Lockheed Martin & Boeing How many parts does the F-22 have? 3 F-22 Raptor Fighter What would
More informationTesting. Topics. Types of Testing. Types of Testing
Topics 1) What are common types of testing? a) Testing like a user: through the UI. b) Testing like a dev: through the code. 2) What makes a good bug report? 3) How can we write code to test code (via
More informationprint statements, debugger expressions, test scripts. Writing expressions in a debugger only that t a program works now. An application typically
JUnit testing Current practice print statements, debugger expressions, test scripts. Writing expressions in a debugger only that t a program works now. An application typically undergoes many changes over
More informationTest automation / JUnit. Building automatically repeatable test suites
Test automation / JUnit Building automatically repeatable test suites JUnit in Eclipse For this course, we will use JUnit in Eclipse It is automatically a part of Eclipse One documentation site (all one
More informationCS159. Nathan Sprague. September 30, 2015
CS159 Nathan Sprague September 30, 2015 Testing Happens at Multiple Levels Unit Testing - Test individual classes in isolation. Focus is on making sure that each method works according to specification.
More informationCSCE 747 Unit Testing Laboratory Name(s):
CSCE 747 Unit Testing Laboratory Name(s): You have been hired to test our new calendar app! Congrats!(?) This program allows users to book meetings, adding those meetings to calendars maintained for rooms
More informationTesting Stragegies. Black Box Testing. Test case
References: Teach Yourself Object-Oriented Programming in 21 Days by A.Sintes, 1 Testing Stragegies Test case a set of inputs and expected outputs looks at specific piece of functionality to determine
More informationChapter 3. Unit Testing with JUnit and Debugging. Testing with JUnit getting started. Note
Chapter 3. Unit Testing with JUnit and Debugging By now, you are past the basics and should be familiar with developing Java applications using the Eclipse IDE. Although you must be feeling very confident
More informationUnit testing. JUnit. JUnit and Eclipse. A JUnit test class 3/6/17. A method is flagged as a JUnit test case.
Unit testing JUnit ENGI 5895 unit testing: Looking for errors in a subsystem in isolation. Generally a "subsystem" means a particular class or object. The Java library JUnit helps us to easily perform
More informationProgrammieren II. Unit Testing & Test-Driven Development. Alexander Fraser.
Programmieren II Unit Testing & Test-Driven Development Alexander Fraser fraser@cl.uni-heidelberg.de (Based on material from Lars Vogel and T. Bögel) July 2, 2014 1 / 62 Outline 1 Recap 2 Testing - Introduction
More informationGood Coding Practices Spring 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Good Coding Practices Spring 2018 1 Introduction 1 2 The Don ts 1 3 The Dos 4 4 CS 18-Specific Practices 5 5 Style 6 1 Introduction
More informationTuesday, November 15. Testing
Tuesday, November 15 1 Testing Testing Waterfall model show testing as an activity or box In practice, testing is performed constantly There has never been a project where there was too much testing. Products
More informationTest-Driven Development (a.k.a. Design to Test) CSE260, Computer Science B: Honors Stony Brook University
Test-Driven Development (a.k.a. Design to Test) CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 Person-hours Labor is sometimes measured in person-hours,
More informationSection 4: Graphs and Testing
Section 4: Graphs and Testing Slides by Erin Peach and Nick Carney with material from Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue AGENDA Graphs JUnit Testing Test Script
More informationUnit testing. unit testing: Looking for errors in a subsystem in isolation. The basic idea: JUnit provides "assert" commands to help us write tests.
JUnit ENGI 5895 Adapted from slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1 Unit testing unit testing: Looking
More informationCS18000: Programming I
CS18000: Programming I Testing Basics 19 April 2010 Prof. Chris Clifton Testing Programs Your programs are getting large and more complex How do you make sure they work? 1. Reason about the program Think
More informationINTRODUCTION TO JAVA PROGRAMMING JAVA FUNDAMENTALS PART 2
INTRODUCTION TO JAVA PROGRAMMING JAVA FUNDAMENTALS PART 2 Table of Contents Introduction to JUnit 4 What is a Test Driven approach? 5 The benefits of a Test Driven Approach 6 What is Continuous Integration?
More informationOOP Design Conclusions and Variations
CS108, Stanford Handout #20 Fall, 2008-09 Osvaldo Jiménez OOP Design Conclusions and Variations Thanks to Nick Parlante for much of this handout Part 1 -- Mainstream OOP Design First, we have the standard,
More informationSection 4: Graphs and Testing
Section 4: Graphs and Testing Slides by Kevin Pusich and Cody Kesting with material from Erin Peach and Nick Carney, Vinod Rathnam, Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Agenda
More informationJUnit Testing Framework Architecture
JUnit Testing Framework Architecture Unit under test (usually a class or a small number of classes) Test environment (fixture) Program state (e.g., some collection of variables/objects that will be used
More informationCSE 331. Unit Testing with JUnit
CSE 331 Unit Testing with JUnit slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1 Bugs and testing software reliability:
More informationWhite box testing. White-box testing. Types of WBT 24/03/15. Advanced Programming
White box testing Advanced Programming 24/03/15 Barbara Russo 1 White-box testing White-box testing is a verification technique software engineers can use to examine if their code works as expected 24/03/15
More informationCS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle
Boggle If you are not familiar with the game Boggle, the game is played with 16 dice that have letters on all faces. The dice are randomly deposited into a four-by-four grid so that the players see the
More informationUnit Testing with JUnit and CppUnit
Unit Testing with JUnit and CppUnit Software Testing Fundamentals (1) What is software testing? The process of operating a system or component under specified conditions, observing or recording the results,
More informationTutorial 3: Unit tests and JUnit
Tutorial 3: Unit tests and JUnit Runtime logic errors, such as contract violations, are among the more frequent in a poorly debugged program. Logic error should be fixed. However, to fix an error we need
More informationThinking Functionally
Thinking Functionally Dan S. Wallach and Mack Joyner, Rice University Copyright 2016 Dan S. Wallach, All Rights Reserved Reminder: Fill out our web form! Fill this out ASAP if you haven t already. http://goo.gl/forms/arykwbc0zy
More informationUnit Testing & Testability
CMPT 473 Software Quality Assurance Unit Testing & Testability Nick Sumner - Fall 2014 Levels of Testing Recall that we discussed different levels of testing for test planning: Unit Tests Integration Tests
More informationAn introduction to formal specifications and JML. Invariant properties
An introduction to formal specifications and JML Invariant properties Yves Ledru Université Grenoble-1 Laboratoire d Informatique de Grenoble Yves.Ledru@imag.fr 2013 Page 1 Invariant properties Invariants
More informationPrinciples of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)
Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems) More Analysis for Functional Correctness Jonathan Aldrich Charlie Garrod School of Computer Science
More information4. A Testing Framework. Oscar Nierstrasz
4. A Testing Framework Oscar Nierstrasz A Testing Framework Sources > JUnit documentation (from www.junit.org) 2 Roadmap > Junit a testing framework > Testing an interface > Testing an algorithm > JExample
More informationhttps://www.lri.fr/ linaye/gl.html
Software Engineering https://www.lri.fr/ linaye/gl.html lina.ye@centralesupelec.fr Sequence 3, 2017-2018 1/61 Software Engineering Plan 1 2 3 4 5 2/61 Software Engineering Software Testing 3/61 Software
More informationStage 11 Array Practice With. Zip Code Encoding
A Review of Strings You should now be proficient at using strings, but, as usual, there are a few more details you should know. First, remember these facts about strings: Array Practice With Strings are
More informationTesting on Steriods EECS /30
1/30 Testing on Steriods EECS 4315 www.eecs.yorku.ca/course/4315/ How to test code? 2/30 input code output Provide the input. Run the code. Compare the output with the expected output. White box testing
More informationTopics covered. Introduction to JUnit JUnit: Hands-on session Introduction to Mockito Mockito: Hands-on session. JUnit & Mockito 2
JUnit & Mockito 1 Topics covered Introduction to JUnit JUnit: Hands-on session Introduction to Mockito Mockito: Hands-on session JUnit & Mockito 2 Introduction to JUnit JUnit & Mockito 3 What is JUnit?
More informationTesters can write good code too. Corina
Testers can write good code too Corina Pip https://iamalittletester.wordpress.com/ Twitter: Blog: https://iamalittletester.wordpress.com/ Travel blog: https://travelwithcori.wordpress.com/ Photos: https://www.flickr.com/photos/capreoara
More informationIntroduction to Software Engineering: Tools and Environments. Session 5. Oded Lachish
Introduction to Software Engineering: Tools and Environments Session 5 Oded Lachish Room: Mal 405 Visiting Hours: Wednesday 17:00 to 20:00 Email: oded@dcs.bbk.ac.uk Module URL: http://www.dcs.bbk.ac.uk/~oded/tools2012-2013/web/tools2012-2013.html
More informationTest Execution and Automation. CSCE Lecture 15-03/20/2018
Test Execution and Automation CSCE 747 - Lecture 15-03/20/2018 Executing Tests We ve covered many techniques to derive test cases. How do you run them on the program? You could run the code and check results
More informationJUnit Framework. Terminology: assertions, annotations, fixtures. Dr. Siobhán Drohan Mairead Meagher. Produced by:
JUnit Framework Terminology: assertions, annotations, fixtures Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topic List General Terminology
More informationBeyond JUnit: Introducing TestNG The Next Generation in Testing
Beyond JUnit: Introducing TestNG The Next Generation in Testing Hani Suleiman CTO Formicary http://www.formicary.net hani@formicary.net TS 3097 2006 JavaOne SM Conference Session TS-3097 Testing Renewed
More informationSoftware Engineering Testing and Debugging Testing
Software Engineering Testing and Debugging Testing Prof. Dr. Peter Thiemann Universitt Freiburg 08.06.2011 Recap Testing detect the presence of bugs by observing failures Debugging find the bug causing
More informationIntroduction to JUnit. Data Structures and Algorithms for Language Processing
Data Structures and Algorithms for Language Processing What is JUnit JUnit is a small, but powerful Java framework to create and execute automatic unit tests Unit testing is the test of a part of a program
More informationSimple TDD Case Study. in Java
Simple TDD Case Study in Java Assertions To check if code is behaving as you expect, use an assertion, a simple method call that verifies that something is true. E.g the method asserttrue checks that the
More informationSoftware Engineering. Unit Testing Gobo Eiffel Test and Clover
Chair of Software Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 June 2007 Unit Testing Gobo Eiffel Test and Clover Agenda for Today 1. Testing 2. Main Concepts 3. Unit Testing Gobo
More informationJava Review via Test Driven Development
Java Review via Test Driven Development By Rick Mercer with help from Kent Beck and Scott Ambler 2-1 Outline What is TDD? Tests as documentation Tests as a way to verify your code works 2-2 Test Driven
More informationSoftware LEIC/LETI. Lecture 5
Software Engineering @ LEIC/LETI Lecture 5 Last Lecture Verification and Validation Reviews and Inspections Software Testing Coverage Statement, branch, and path coverage Equivalence partitioning Boundary
More informationAnnotations in Java (JUnit)
Annotations in Java (JUnit) Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhán Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ What are Annotations? They
More informationTest First Software Development
Test First Software Development Jacob Kristhammar Roger Schildmeijer D04, Lund Institute of Technology, Sweden {d04jk d04rp}@student.lth.se 2008-02-06 Abstract In this in-depth study we will try to explain
More informationJUnit on Eclipse. Chien-Tsun Chen Sep. 23, 2003
JUnit on Eclipse Chien-Tsun Chen Sep. 23, 2003 ctchen@ctchen.idv.tw Outline Introduction to JUnit Using JUnit on Eclipse, By Example Resources Q&A Introduction to JUnit What is JUnit? JUnit is an open
More informationChapter 9. Software Testing
Chapter 9. Software Testing Table of Contents Objectives... 1 Introduction to software testing... 1 The testers... 2 The developers... 2 An independent testing team... 2 The customer... 2 Principles of
More informationTesting. My favourite testing quote: Program testing can be used to show the presence of bugs, but never to show their absence!
Testing Some resources The most time-consuming of a development project. See for example https://www.itu.dk/people/sestoft/ papers/softwaretesting.pdf - Peter Sestoft testing notes Testing My favourite
More informationBinghamton University. CS-140 Fall Unit Testing
Unit Testing 1 Test Early, Test Often 2 Informal Unit Testing public static void main(string[] args) { Rectangle rect = new Rectangle ( new Point(20,30), 20,40 ); System.out.println("Created " + rect);
More informationULC Test Framework Guide. Canoo RIA-Suite 2014 Update 4
ULC Test Framework Guide Canoo RIA-Suite 2014 Update 4 Canoo Engineering AG Kirschgartenstrasse 5 CH-4051 Basel Switzerland Tel: +41 61 228 9444 Fax: +41 61 228 9449 ulc-info@canoo.com http://riasuite.canoo.com/
More informationSoftware Engineering
Software Engineering Lecture 13: Testing and Debugging Testing Peter Thiemann University of Freiburg, Germany SS 2014 Recap Recap Testing detect the presence of bugs by observing failures Recap Testing
More informationJUnit + JMock Tomáš Soukup
JUnit + JMock 29.11.2011 Tomáš Soukup JUnit - intro Java framework for creating and running unit tests Test case method 1 public(protected) method 1+ test methods Test suite class set of test cases (methods)
More informationProvided Files that Are Fine
Fixing How to Play 2048 - Consists of a 4x4 grid of tiles with numbers on them - Use arrow keys to move tiles in a direction - Tiles will keep moving until they hit a wall or another tile - Every movement
More informationAdvanced Software Engineering
Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma Advanced Software Engineering Implementation and Maintenance Prof. Agostino Poggi Implementation
More information3 Continuous Integration 3. Automated system finding bugs is better than people
This presentation is based upon a 3 day course I took from Jared Richardson. The examples and most of the tools presented are Java-centric, but there are equivalent tools for other languages or you can
More informationCS201 - Assignment 3, Part 1 Due: Friday February 28, at the beginning of class
CS201 - Assignment 3, Part 1 Due: Friday February 28, at the beginning of class One of the keys to writing good code is testing your code. This assignment is going to introduce you and get you setup to
More informationBinghamton University. CS-140 Fall Unit Testing
Unit Testing 1 Test Early, Test Often 2 Informal Unit Testing package lab05; import java.lang.illegalargumentexception; public class ProfTest { public static void main(string[] args) { System.out.println("Professor
More informationApacheCon NA How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum
ApacheCon NA 2015 How to Avoid Common Mistakes in OFBiz Development Presented by Adrian Crum 1Tech, Ltd. 29 Harley Street, London, W1G 9QR, UK www.1tech.eu 1 Overview Common Getting Started Problems Common
More informationPractical Objects: Test Driven Software Development using JUnit
1999 McBreen.Consulting Practical Objects Test Driven Software Development using JUnit Pete McBreen, McBreen.Consulting petemcbreen@acm.org Test Driven Software Development??? The Unified Process is Use
More informationCS11 Advanced Java. Winter Lecture 2
CS11 Advanced Java Winter 2011-2012 Lecture 2 Today s Topics n Assertions n Java 1.5 Annotations n Classpaths n Unit Testing! n Lab 2 hints J Assertions! n Assertions are a very useful language feature
More informationFunctional Testing (Testování funkčnosti)
Functional Testing (Testování funkčnosti) http://d3s.mff.cuni.cz Pavel Parízek parizek@d3s.mff.cuni.cz CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Nástroje pro vývoj software Functional
More informationClasses, interfaces, & documentation. Review of basic building blocks
Classes, interfaces, & documentation Review of basic building blocks Objects Data structures literally, storage containers for data constitute object knowledge or state Operations an object can perform
More informationSoftware-Architecture Unit Testing (JUnit)
Software-Architecture Unit Testing (JUnit) Prof. Dr. Axel Böttcher 10. Oktober 2011 Objectives Understand the concept of unit testing Know how to write unit tests Know when to write unit tests Why Unit-Testing?
More informationBlack Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing
Black Box Testing EEC 521: Software Engineering Software Testing Black-Box Testing Test-Driven Development Also known as specification-based testing Tester has access only to running code and the specification
More informationCredit where Credit is Due. Lecture 29: Test-Driven Development. Test-Driven Development. Goals for this lecture
Lecture 29: Test-Driven Development Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Credit where Credit is Due Some of the material for this lecture is taken from
More informationProgram development plan
Appendix A Program development plan If you are spending a lot of time debugging, it is probably because you do not have an effective program development plan. A typical, bad program development plan goes
More informationChecking Current Code Coverage
Junit Tests Checking Current Code Coverage We use onap Sonar to track code coverage (sonar.onap.org) To see the appc coverage, click on the appc project on the front page (make sure you choose the most
More informationCS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM
CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,
More informationTesting, code coverage and static analysis. COSC345 Software Engineering
Testing, code coverage and static analysis COSC345 Software Engineering Outline Various testing processes ad hoc / formal / automatic Unit tests and test driven development Code coverage metrics Integration
More informationStephen Edwards. What is unit testing? Manuel Pérez- Quiñones. Virginia Tech. You betcha! For you: Repeatedly check behaviors of many student programs
Software test == a check on the behavior of some piece of code The Absolute Beginner s Guide to JUnit in the Classroom Stephen Edwards Manuel Pérez- Quiñones Virginia Tech What is unit testing? Unit test
More information1: Introduction to Object (1)
1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface
More informationAccessibility. Adding features to support users with impaired vision, mobility, or hearing
Accessibility Adding features to support users with impaired vision, mobility, or hearing TalkBack TalkBack is an Android screen reader made by Google. It speaks out the contents of a screen based on what
More informationmvn package -Dmaven.test.skip=false //builds DSpace and runs tests
DSpace Testing 1 Introduction 2 Quick Start 2.1 Maven 2.2 JUnit 2.3 JMockit 2.4 ContiPerf 2.5 H2 3 Unit Tests Implementation 3.1 Structure 3.2 Limitations 3.3 How to build new tests 3.4 How to run the
More informationTopics. Software Testing Test Driven Development Black Box Testing Unit Testing White Box Testing Coverage Testing Software Debugging
Supplemental Materials: Software esting CS2: Data Structures and Algorithms Colorado State University Chris Wilcox, Russ Wakefield, Wim Bohm, Dave Matthews opics Software esting est Driven Development
More informationExamples. Stack. VideoPlayer
Examples Stack VideoPlayer 1 Stack Interface public interface Stack public String pop (); public void push (String item); public String top (); public boolean isempty (); 2 public class ArrayStack implements
More informationWhat is software testing? Software testing is designing, executing and evaluating test cases in order to detect faults.
ϖοιδ τεσταδδανδχουντ() { ασσερ τεθυαλσ(1, ο.αδδανδχουντ(νεω ΑρραψΛιστ()); ϖοιδ τεσταδδανδχουντ() { ασσερ τεθυαλσ(1, ο.αδδανδχουντ(νεω ΑρραψΛιστ()); ιντ αδδανδχουντ(λιστ λιστ) { ρετυρν λιστ.σιζε(); ιντ
More informationThe compiler is spewing error messages.
Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More information