L05cs2110f09-6up - CS 2110 Based on slides originally by...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 2110 Software Desig Based on slides originally by Juan Altmayer Pizzorno port25.com n Principles II
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
verview Overview ± Last week: ² Design Concepts & ² Refactoring ± Today : Test-Driven DD + Unit y xa ² TDD + JUnit by Exa e use Unit sting ± We use JUnit testing homework assignme Principles Development ple mple to evaluate your to evaluate your nts…
Background image of page 2
ests can be gre Tests can be gre “In my coun testing is many t! at! try of Kazakhstan very nice! Make tests please!
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
esting can be g Testing can be g ± Many people ± Write code without bei ± Press run and pray ± If it fails, they change s ± This ± Never works ± And ruins your Friday ± Test-Driven Developm eat! reat! ng sure it will work omething random evening social plans ent saves the day!
Background image of page 4
he Example The Example ± A collection class Sm ² containing up to N o ² typical operations: add contains size ² we’ll implement add allSet bjects (hence “small”) adds item item in the set? # items () , size()
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
est Driven Dev Test Driven Dev ± We’ll go about in sm 1. add a test 2. run all tests and wat 3. make a small chang 4. run all tests and see 5. refactor (as needed) e’ll use Unit ± We ll use JUnit lopment elopment all iterations ch the new one fail e them all succeed
Background image of page 6
Unit JUnit ± What do JUnit tests SmallSet.java S package edu.cornell.cs.cs2110; public class SmallSet { .. p i i ... } p } look like? mallSetTest.java ackage edu.cornell.cs.cs2110; mport org.junit.Test; mport static org.junit.Assert.*; ublic class SmallSetTest { @Test public void testFoo () { mallSet = new mallSet ); SmallSet s = new SmallSet(); ... assertTrue (...); } @Test public void testBar() { ... }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
List of Tests A List of Tests ± We start by thinking not how to implemen ² size=0 on empty set ² size=N after adding ² adding element alre ² throw exception if ad ² ... ± Each test verifies a c about how to test, t N distinct elements ady in set doesn’t change it ding too many ertain “feature”
Background image of page 8
First Test A First Test ± We pick a feature and SmallSet class SmallSet {} SmallSetTest class SmallSetTest { @Test public void tes SmallSet s = new S assertEquals(0, s ± This doesn’t compile: } } ± But that’s all right: we interface by using it test it: tEmptySetSize() { mallSet(); .size()); size() is undefined ’ve started designing the
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 27

L05cs2110f09-6up - CS 2110 Based on slides originally by...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online