Tools for Integration Testing



Similar documents
Testing, Debugging, and Verification

Chapter 11: Integrationand System Testing

Software testing. Objectives

Unit Testing & JUnit

Unit Testing. and. JUnit

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Chapter 11: Integration- and System Testing

Java course - IAG0040. Unit testing & Agile Software Development

Slides prepared by : Farzana Rahman TESTING WITH JUNIT IN ECLIPSE

Unit Testing and JUnit

Software Engineering I: Software Technology WS 2008/09. Integration Testing and System Testing

Chapter 11, Testing, Part 2: Integration and System Testing

CS 451 Software Engineering Winter 2009

Software Engineering. How does software fail? Terminology CS / COE 1530

Java Application Developer Certificate Program Competencies

Author: Sascha Wolski Sebastian Hennebrueder Tutorials for Struts, EJB, xdoclet and eclipse.

Chapter 8 Software Testing

Testing and Inspecting to Ensure High Quality

Java Interview Questions and Answers

AP Computer Science Java Subset

Java Unit testing with JUnit 4.x in Eclipse

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Java (12 Weeks) Introduction to Java Programming Language

Karunya University Dept. of Information Technology

JUnit Automated Software Testing Framework. Jeff Offutt. SWE 437 George Mason University Thanks in part to Aynur Abdurazik. What is JUnit?

How To Develop Software

Introduction to Automated Testing

EVALUATING METRICS AT CLASS AND METHOD LEVEL FOR JAVA PROGRAMS USING KNOWLEDGE BASED SYSTEMS

Software development life cycle. Software Engineering - II ITNP92 - Object Oriented Software Design. Requirements. Requirements. Dr Andrea Bracciali

Outline. 1 Denitions. 2 Principles. 4 Implementation and Evaluation. 5 Debugging. 6 References

Patterns in. Lecture 2 GoF Design Patterns Creational. Sharif University of Technology. Department of Computer Engineering

Part I. Multiple Choice Questions (2 points each):

PRIMARY CONTENT MODULE Algebra I -Linear Equations & Inequalities T-71. Applications. F = mc + b.

Programming Languages CIS 443

APPENDIX A: MOCKITO UNIT TESTING TUTORIAL

(Refer Slide Time: 01:52)

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Design by Contract beyond class modelling

Software Development Process Models

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

CS 111 Classes I 1. Software Organization View to this point:

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction

Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

Unit-testing with JML

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

International Journal of Advanced Engineering Research and Science (IJAERS) Vol-2, Issue-11, Nov- 2015] ISSN:

Getting Started with the Internet Communications Engine

Experimental Comparison of Concolic and Random Testing for Java Card Applets

Standard for Software Component Testing

Moving from CS 61A Scheme to CS 61B Java

Test-Driven Development

The Snake Game Java Case Study

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces

Software Engineering. Software Testing. Based on Software Engineering, 7 th Edition by Ian Sommerville

Introduction to Software Testing Chapter 8.1 Building Testing Tools Instrumentation. Chapter 8 Outline

Formal Engineering for Industrial Software Development

Software quality engineering. Quality assurance. Testing

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Approach of Unit testing with the help of JUnit

Basic Unix/Linux 1. Software Testing Interview Prep

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

J a v a Quiz (Unit 3, Test 0 Practice)

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

RUP. Development Process. Iterative Process (spiral) Waterfall Development Process. Agile Development Process. Well-known development processes

Java Programming Language

1 White-Box Testing by Stubs and Drivers


C++ Programming Language

Writing Self-testing Java Classes with SelfTest

Table of Contents. LESSON: The JUnit Test Tool...1. Subjects...2. Testing What JUnit Provides...4. JUnit Concepts...5

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

Explain the relationship between a class and an object. Which is general and which is specific?

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from

Chapter 12 Programming Concepts and Languages

Hypercosm. Studio.

Designing with Exceptions. CSE219, Computer Science III Stony Brook University

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Using JUnit in SAP NetWeaver Developer Studio

Software Testing. Quality & Testing. Software Testing

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

The Phases of an Object-Oriented Application

Alarms & Events Plug-In Help Kepware, Inc.

Software Engineering. What is a system?

Appium mobile test automation

UML-based Test Generation and Execution

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

16.1 DataFlavor DataFlavor Methods. Variables

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Agile.NET Development Test-driven Development using NUnit

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Automated Module Testing of Embedded Software Systems

Business Process Discovery

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Tutorial IV: Unit Test

Transcription:

Tools for Integration Testing

What is integration ing? Unit ing is ing modules individually A software module is a self-contained element of a system Then modules need to be put together to construct the complete system Construction of a working system from the pieces is not a straightforward task because of numerous interface errors Objective of system integration ing (SIT) to build a working version of the system putting modules together ensuring that the additional modules work as expected without disturbing the functionalities of the modules already put together

What is integration ing? Integration ing is said to be complete when The system is fully integrated together All the cases have been executed All the severe and moderated defects found have been fixed

Types of module interfaces Common paradigms for interfacing modules: Procedure call interface Shared memory interface Message passing interface The problem arises when we put modules together because of interface errors Interface errors Interface errors are those that are associated with structures existing outside the local environment of a module, but which the module uses

Types of Interface Errors Construction Inadequate error processing Inadequate functionality Additions to error processing Location of functionality Inadequate post-processing Changes in functionality Inadequate interface support Added functionality Initialization/value errors Misuse of interface Validation od data constraints Misunderstanding of interface Timing/performance problems Data structure alteration Coordination changes Hardware/software interfaces 5

Different scopes of Integration Intra Class Integration concerns different methods within a class Typical strategy : constructors accessors predicates modifiers iterators destructors Package Integration Integration concerns classes within a package Subsystem/System Integration Integration of packages 6

System Integration Techniques Common approaches for system integration ing Top-down Bottom-up Sandwich Big-bang 7

Components for Integration Testing When ing a module in isolation Called modules need to be replaced Tested module needs to be called main driver A module under D E stubs

Top down Integration Incremental strategy 1. Test high level modules, then 2.Modules called until lowest level modules main main A B C main, A, B,C D E F main, A, B, C D, E, F

Top down Integration Possible to alter order such to as early as possible critical units input/output units main main main, A,C A B C main, A,C, D,F D E F main, A, B, C D, E, F

Advantages Top down Integration Fault localization easier Few or no drivers needed Possibility to obtain an early prototype Different order of ing/implementation possible Major design flaws found first in logic modules on top of the hierarchy Dis advantages Need lot of stubs Potentially reusable modules (in bottom of the hierarchy) can be inadequately ed

Bottom up Integration Incremental strategy 1. Test low level modules, then 2.Modules calling them until highest level module main D D,E,A A B C E B main, A, B, C D, E, F D E F F C,F

Bottom up Integration Advantages Fault localization easier (than big bang) No need for stubs Reusable modules ed thoroughly Testing can be in parallel with implementation Dis advantages Need of drivers High level modules (that relate to the solution logic) ed in the last (and least) No concept of early skeletal system

Sandwich Integration Combines top down and bottom up approaches Distinguish 3 layers logic (top) ed top down middle operational (bottom) ed bottom up D main D,E,A A B C D E F E F main C,F main, A, B, C main, A, B, C D, E, F

Modified Sandwich Integration Combines top down and bottom up approaches Modules ed first in isolation before integration D D,E,A A main A B C E F C,F C main, A, B, C D, E, F D E F main main,a,b,c B

Big Bang Integration Non incremental strategy 1. Unit each module in isolation 2.Integrate as a whole main A B C D E F A C E main B D F main, A, B, C D, E, F

Big Bang Integration Advantages convenient for small systems Dis advantages need driver and stubs for each module do not allow parallel development fault localization difficult easy to miss interface faults

Drivers A driver is a method used to call a module that is being ed. Sends values to module under. Collects return values JUnit cases essentially are drivers. The following could also be a driver: public class TestSomething public static void main ( String[] args ) int result = 0; double send = 98.6; Whatever what = new Whatever; System.out.println( Sending somefunc 98.6. ); result = what.somefunc( send ); System.out.println( SomeFunc returned: + result );

Stubs A stub is a module used specifically for ing that replaces a called module. Why? To gain access to an interface that is otherwise not visible. Actual module is not ready or reliable. Actual module would be a component such as a database, network requiring a large amount of setup.

Creating a Stub The stub must have the same signature as the real module. Same name, parameter list, return value type, modifiers (static, public, etc.) Function: If the module is called, check that the incoming parameters are as expected. Provide suitable return values. The stub should not attempt to replicate the functionality of the actual module. Instead, preset return values should be used.

Example of a Stub Method signature: public static int somemethod(int aparameter) A possible stub for this method public static int somemethod(int aparameter) int result = 42; System.out.println ( In somemethod(): + Input int = + aparameter); System.out.println ( Returning 42. ); return result;

Common Stub functions Display/log trace message Display/log passed parameters Return a value according to objective. This could be determined from: a table an external file based on a search according to parameter value

Stubs multiple calls void main() int x, y; // 1 x = TestMe1.a(); if (x > 0) // 2 y = TestMe2.b(x); TestMe3.c(y); else // 3 TestMe3.c(x) System.exit(0); // 4 Test for path 1 2-4 Stub for TestMe1.a() needs to return x > 0 Test for path 1 3 4 6 7 Stub for TestMe1.a() needs to return x <= 0 Stub will have to be able to return the appropriate values depending on the sequence of calls. Problem: stubs can become too complex

Mock Objects as Stubs A mock object is used as a substitute object in a situation where a stub is called for. Set up variables within objects to have interface types instead of specific class types. Multiple classes can implement the interface, if necessary. In particular, a mock object class can also implement the interface, effectively making object instances as stubs. Can be refined incrementally by replacing with actual code

Dependent class associations Many classes are set up so that associated classes are referred to specifically by their name, as a type for the association reference variable. This makes it difficult to replace the dependent class. class under (CUT) dependent class referenced by CUT

Dependent Classes Client is the class which we would like to. Helper is a class used by Client. Reasons for replacing Helper: If it was not ready We want direct control over what is sent to Client.

Example We are going to a class called TestMe. The class is a wrapper around a class called Converter that will convert Celsius to Fahrenheit. Class Converter has two methods: Method to convert Celsius temperatures to Fahrenheit temperatures. Method to convert Fahrenheit temperatures to Celsius temperatures. Class TestMe is a wrapper to this class that has one method convert(), and uses constants from an enumerated type ConversionType to choose the conversion direction.

Example Class TestMe creates the Converter object and keeps a reference to it. The TestMe object chooses which method to call in Converter. The Converter object does the appropriate conversion, and returns its result to the TestMe object.

Creation of associated object The Converter object is created by the TestMe constructor: private Converter converter; public TestMe( ) converter = new Converter( );

TestMe functionality public Double convert( Double temperature, ConversionType direction ) Double result = null; if ( converter!= null ) switch ( direction ) case C_TO_F: result = converter.convertctof( temperature ); break; case F_TO_C: result = converter.convertftoc( temperature ); break; else throw new IllegalStateException( "No converter specified" ); return result;

Class ConversionDirection // Constants to specify conversion direction public enum ConversionType F_TO_C, C_TO_F;

Class Converter public class Converter public Double convertctof( Double temperature ) return new Double( temperature.doublevalue( ) * 9.0 / 5.0 + 32.0 ); public Double convertftoc( Double temperature ) return new Double( ( temperature.doublevalue( ) - 32.0 ) * 5.0 / 9.0 );

Portion of a Test Case for TestMe private TestMe Me; private static double tolerance = 0.0001; @Before public void setup() Me = new TestMe(); @Test public void CtoF_Freezing( ) double input = 0.0; double expected = 32.0; double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

Goals: At present, class TestMe is tied to a specific type of object. Modifications need to be made to TestMe if other types are used. We could use subclasses of Converter, but these subclasses still inherit behaviour from Converter. This functionality may not be complete. Does not provide for replacing Converter objects quickly. Alternative: use the interface mechanism.

Dependent class associations with interfaces Have classes store references using interface types instead of classes. Mock object can then implement the interface with minimal functionality class under (CUT) interface referenced by CUT mock object implementation class

Class dependencies object creation Another factor that can make using mock objects more difficult is when an object creates its dependent objects. Using new ObjectClassName() to create an object still ties the associated object to a particular class, even if the reference is then assigned to an interface type. class under (CUT) object created by CUT

Use of interfaces Create an interface IHelper. Class Client now has an association with IHelper instead of Helper. Any class that implements the IHelper interface can replace Helper. Class MockHelper will be a mock object that can replace Helper.

Strategies Design for ability (but you tell the designers that they are designing for extensibility / maintenance ) Option 1: Use the inversion of control pattern. Option 2: Use the (Abstract) Factory pattern

Inversion of Control Pattern The rule for this pattern is that objects should not directly create any objects for which they might have an association. If object A is supposed to work with object B, then A should not create B. Instead, A and B should be created separately, and then they are passed references to each other.

Inversion of Control Pattern Rationale: For future extensibility, the objective is to increase the independence of classes. If object B is replaced by object B, version 2.0, class A doesn t have to be changed. Rationale for ing: We can replace real object B by a mock object for the purpose of ing object A.

Example: Interfaces and inversion of control

Example: Interfaces and inversion of control Class TestMe now has an association with IConverter instead of Converter. Instead of having TestMe create a Converter object, a reference to an IConverter is passed in via an accessor method. A reference to IConverter is then stored within TestMe. Either a Converter or MockConverter can be created, and then passed to TestMe via the accessor. A case can create either the real or the mock object as appropriate.

Interface Converter // Interface for class to be mocked. // Implementation will convert Fahrenheit to // Celsius, or vice versa public interface Converter public double convertftoc( double temp ); public double convertctof( double temp );

The actual object public class Converter implements IConverter public Double convertctof( Double temperature ) return new Double( temperature.doublevalue( ) * 9.0 / 5.0 + 32.0 ); public Double convertftoc( Double temperature ) return new Double( ( temperature.doublevalue( ) - 32.0 ) * 5.0 / 9.0 );

The mock object public class MockConverter implements IConverter // Objective: for a few cases we know without using the // formulas, return the appropriate results. public Double convertctof( Double temperature ) Double result = null; if ( temperature.equals( 0.0 ) ) // Freezing result = new Double( 32.0 ); else if ( temperature.equals( 100.0 ) ) // Boiling result = new Double( 212.0 ); else if ( temperature.equals( 37.0 ) ) // Body temp. result = new Double( 98.6 ); else if ( temperature.equals( -40.0 ) ) // Same! result = new Double( -40.0 ); return result; // Similar implementation of convertftoc

Testing using the real Converter private TestMe Me; private IConverter converter; private static double tolerance = 0.0001; @Before public void setup() Me = new TestMe(); converter = new Converter(); Me.setConverter( converter ); @Test public void CtoF_Freezing( ) double input = 0.0; double expected = 32.0; double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

Testing using the mock Converter private TestMe Me; private IConverter mock; private static double tolerance = 0.0001; @Before public void setup() Me = new TestMe(); mock = new MockConverter(); Me.setConverter( mock ); Creation of the helper object is the only code that needs to change. @Test public void CtoF_Freezing( ) double input = 0.0; double expected = 32.0; double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

Factory Pattern Objective is to isolate the creation of any objects used in an application. Rationale: As class names change through software evolution, only the Factory needs to be updated. A class known as a factory will be responsible for any object creation, Whenever the application needs a new object, ask the factory class to create the object. Alternative: create a single Factory object from the Factory class.

Abstract Factory Pattern With this approach, the Factory is itself an interface, and there could be several implementations of the Factory. Rationale (by example): An application may want to create a user interface button, and so it asks the abstract factory to create an object. There could be three implementations of the Factory, one of which is currently active: Windows (as in Microsoft) factory X-Windows (for Linux, etc.) factory Macintosh button factory Rationale for ing: Substitute a Factory that creates mock objects.

UML diagram of Abstract Factory pattern

Example, using Abstract Factory Pattern

Example: Factory interface and public interface IFactory IConverter createproduct(); classes public class Factory implements IFactory public IConverter createconverter( ) return new Converter( ); // Creates the real object public class MockFactory implements IFactory public IConverter createconverter( ) return new MockConverter( ); // Creates a mock object

In Class TestMe private static IFactory factory = null; private IConverter converter; public TestMe( ) converter = null; if ( factory!= null ) converter = factory.createconverter( ); public static void setfactory( IFactory thefactory ) TestMe.factory = thefactory;

Testing using the production factory private TestMe Me; private static IFactory factory; private static double tolerance = 0.0001; @BeforeClass public void setupbeforeclass() factory = new Factory(); TestMe.setFactory( factory ); @Before public void setup() Me = new TestMe(); @Test public void CtoF_Freezing( ) double input = 0.0; double expected = 32.0; double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

Testing using the mock factory private TestMe Me; private static IFactory factory; private static double tolerance = 0.0001; @BeforeClass public void setupbeforeclass() factory = new MockFactory(); TestMe.setFactory( factory ); @Before public void setup() Me = new TestMe(); Creation of the specific object factory is the only code that needs to change. @Test public void CtoF_Freezing( ) double input = 0.0; double expected = 32.0; double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

Automating Mock Object Creation What did we have to do to create the mock object? Identify methods that can be called. Create a few cases where we know the output for given input. Identify the input as a known case. Return the associated output. Objective: build a mock object automatically. Structure can be determined using Java s reflection capability. Capability to allow user to specify the mock object s behaviour easily needs to be provided.

Frameworks for Mock Objects EasyMock and jmock are two frameworks for creating mock objects at run time. Use Java reflection to create a mock object class that matches an interface. EasyMock Open source project on SourceForge. web site: www.easymock.org current version: 2.5.2 (Sept. 2009) jmock Open source project on Codehaus web site: www.jmock.org current version 2.5.1 (Aug. 2008)

EasyMock Usage General steps: 1. Create the mock object 2. Tell the mock object how to behave when called. 3. Activate the mock object (this is called replay in the EasyMock documentation) 4. Use the mock object during a. 5. After the has run, check with the mock object to see if the expected calls were made.

Mock Object Creation A call to the EasyMock framework will generate a mock object. Specify a Java object of type Class as the parameter to the method call. Normally, this would be an interface. At this point, you can specify whether the mock object is to have strict behaviour. Normal: mock object will not enforce the ordering of calls to its methods. Strict: calls to mock object methods must be in the sequence that is specified.

Example: Creation of Mock Object import org.easymock.easymock; private TestMe Me; private IConverter mock; @Before public void setup( ) Me = new TestMe( ); mock = EasyMock.createMock( IConverter.class ); Me.setConverter( mock );

Specify the Mock Object behaviour Items to do: Select a method in the mock object that could be called. For that method: Provide a set of input parameter values to be matched. Provide a value to be returned when the method is called with those parameter values.

Specify the Mock Object behaviour Mechanism: Option 1: If no value needs to be returned, just make the method call on the mock object with a parameter value that should be provided. Option 2: If a value needs to be returned, use the EasyMock static method expect() with the method call (a Method object) as a parameter. The return value is of a type that permits calling a method andreturn(). The parameter to that method will be the return value when the input matches the values that appear in the call to expect().

Set up mock object behaviour @Test public void CtoF_Freezing( ) Reference to mock object EasyMock.expect( mock.convertctof( 0.0 ) ).andreturn( 32.0 ); // Activate mock object Called method // Rest of case Case is when parameter matches this value. When method is called with input parameter 0.0, return the value 32.0

Activating the Mock Object After specifying the mock object s future behaviour, the next step is to activate it. With the active mock object, we can then run our s that call the object under that collaborates with the mock object.

Set up mock object behaviour, and run @Test public void CtoF_Freezing( ) EasyMock.expect( mock.convertctof( 0.0 ) ).andreturn( 32.0 ); EasyMock.replay( mock ); Activate mock object double input = 0.0; Remainder of is double expected = 32.0; as usual. double actual = Me.convert( input, ConversionType.C_TO_F ); assertequals( expected, actual, tolerance );

After the We want to be sure that the mock object actually received the expected calls. The EasyMock framework provides a verify() method that takes the mock object as a parameter. If the expected calls occurred, the method will return. If an expected call was missed, an exception will be thrown. This exception will cause a JUnit failure.

Verification of calls to mock private IConverter mock; @After public void teardown( ) EasyMock.verify( mock ); object

Additional EasyMock Features Specifying a number of repeated calls with the same input parameters. Specifying that the mock object is to throw an exception when a method is called with a specified value. Specifying that a method should be called with specified values: At least once Between min and max number of times Any number of times Pattern matching on input values, instead of equality.

jmock Usage General steps: 1. Create the mock object 2. Define the expectations for the mock object. 3. Use the mock object during a. The runner will ensure that the expectations are met, or the case will fail. Caveat: jmock s runner looks for internal classes within junit.jar. The classes are available in junit.jar if you download the library from junit.org, but are not in the version of the JUnit library installed within Eclipse.

jmock JUnit structure import org.jmock.expectations; import org.jmock.mockery; import org.jmock.integration.junit4.jmock; import org.jmock.integration.junit4.junit4mockery; @RunWith( JMock.class ) public class JMockTest private Mockery context = new JUnit4Mockery(); // s go here

Mock Object Creation jmock uses an interface called Mockery to represent the context in which a mock object is used. Create an instance of a Mockery specific to the version of JUnit: Mockery context = new JUnit4Mockery(); To create a mock object: IConverter mock = context.mock( IConverter.class ); Specify a Java object of type Class as the parameter to the method call. Normally, this would be an interface.

Example: Creation of Mock Object private TestMe Me; private Mockery context = new JUnit4Mockery(); IConverter mock; @Before public void setup( ) Me = new TestMe( ); mock = context.mock( IConverter.class ); Me.setConverter( mock );

Specify the Mock Object behaviour jmock defines behaviour using expectations. Each expectation consists of: An invocation count A mock object method call reference, with specified parameter values [optional] An action to perform. example: return a value.

Invocation counts exactly(n).of( m ) Method m must be called exactly n times. atleast(n).of( m ) Method m must be called n or more times. atmost(n).of( m ) Method m must be called n or fewer times. between(min,max).of( m ) allowing( m ) never( m ) Method m must be called at lest min times and at most maxtimes. Method m can be called, but does not have to be called. Method m cannot be called. one( m ) A shorthand for exactly( 1 ).of( m )

Define expectations @Test Reference to mock object public void CtoF_Freezing( ) context.checking( new Expectations( ) Called method one( mock ).convertftoc( 32.0 ); will( returnvalue( 0.0 ) ); ); Invocation count // Rest of case Expected parameter value Action when parameter is matched: return value