sensing separation
Download
Skip this Video
Download Presentation
Sensing & Separation

Loading in 2 Seconds...

play fullscreen
1 / 6

Sensing & Separation - PowerPoint PPT Presentation


  • 104 Views
  • Uploaded on

Sensing & Separation. Feathers Ch 3 Steve Chenoweth, RHIT. How to break dependencies. Sensing – Break dependencies in order to sense, whenever we can’t access values our code computes.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Sensing & Separation' - thy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
sensing separation

Sensing & Separation

Feathers Ch 3

Steve Chenoweth, RHIT

how to break dependencies
How to break dependencies
  • Sensing – Break dependencies in order to sense, whenever we can’t access values our code computes.
  • Separation – Break dependencies to separate when we can’t even get a piece of code into a test harness to run.

Right – You can’t test the sled unless the dogs are in the harness!

Q10

slide3
E.g.,

public class NetworkBridge

{

public NetworkBridge(EndPoint [] endpoints) {

}

public void formRouting(String sourceID, String destID) {

}

}

How do we write tests for this?

What if the hardware is not available?

This is the “sensing and separation” problem.

so we fake collaborators
So, we Fake collaborators
  • Like the “Mock Objects” you studied in 376:
  • A mock object is a fake object in the system that decides whether the unit test has passed or failed.
  • In general, a “Fake Object” impersonates some collaborator of your class, when your class is being tested.
fake tests are real tests
Fake Tests are Real Tests
  • May not show everything, but
  • We try to get close!
  • We hope for small, well-understood pieces.

Right – Is the chocolate working for you?

How about the berries?

Q11

example
Example

import junit.framework.*;

public class SaleTest extends TestCase

{

public void testDisplayItem() {

FakeDisplay display = new FakeDisplay();

Sale sale = new Sale(display);

sale.scan(“1”);

assertEquals(“Milk $3.99”, display.getLastLine3());

}

}

ad