Smalltalk Connections 1 Test Driven Development (TDD) Presented by Victor Goldberg, Ph.D.

Slides:



Advertisements
Similar presentations
SPL/2010 Test-Driven Development (TDD) 1. SPL/
Advertisements

xUnit Test Patterns (Some) xUnit Test Patterns (in practice) by Adam Czepil.
Test-First Programming. The tests should drive you to write the code, the reason you write code is to get a test to succeed, and you should only write.
Acceptance Testing.
Roles of Variables with Examples in Scratch
Computer Science 209 Testing With JUnit. Why Test? I don ’ t have time, I ’ ve got a deadline to meet The more pressure I feel, the fewer tests I will.
Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
Test-Driven Development. Why Testing is Important? “If you don’t have tests, how do you know your code is doing the thing right and doing the right thing?”
Math notebook, pencil, and possibly calculator. Definitions  An outcome is the result of a single trial of an experiment.  The sample space of an experiment.
PS4: Test Driven Development Based on Test Driven Development by Example By Kent Beck.
CHE 185 – PROCESS CONTROL AND DYNAMICS
1 JASS 2006, Sergey Konovalov, Stefan Misslinger XP Extreme Programming Joint Advanced Student School (JASS) XP EXTREME PROGRAMMING.
The Simplest Automated Unit Test Framework That Could Possibly Work Chuck Allison.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Test Data Generators Lecture 5. Why Distinguish Instructions? Functions always give the same result for the same arguments Instructions can behave differently.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Eclipse[10] MIPSinEclipse. Overview Goal: To provide a friendly development environment for CS students programming in MIPS (particularly CS33 at UCLA),
© S. Demeyer, S. Ducasse, O. Nierstrasz Chapter.1 Unit Testing Explained How to support changes? How to support basic but synchronized documentation?
Red-Green-Refactor! EclipseCon 2008 Kevin P. Taylor, Nicolaus Malnick Test-Driven Development (TDD) for Eclipse RCP.
TDD OVERVIEW OF TEST DRIVEN DEVELOPMENT by Paul M. code of the damned. com.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
By for Test Driven Development: Industry practice and teaching tool Robert Vanderwall, Ph.D. 1 WISTPC-15.
TDD,BDD and Unit Testing in Ruby
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Test Driven Development An approach to writing better code Jimmy Zimmerman Intel Corporation.
Computer Science and Engineering College of Engineering The Ohio State University JUnit The credit for these slides goes to Professor Paul Sivilotti at.
Describing Methodologies PART II Rapid Application Development* Systems Analysis and Design II.
Scratch programming and Numeracy in Senior Primary Classes (NCTE/Lero) Summer Course 2012 Module 4 © Lero, NCTE 2012.
Testing Michael Ernst CSE 140 University of Washington.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
October, 2006 © Copyright 2006, Larry A. Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is preserved.
Using handheld computers to support the collection and use of reading assessment data Naomi Hupert.
CSC 213 – Large Scale Programming. Today’s Goal  Improve design skills to make usable designs  Noun extraction & UML class diagram reviewed  Connections.
LECTURE 14 TUESDAY, 13 OCTOBER STA 291 Fall
A tool for test-driven development
Spreadsheet Engineering Builders use blueprints or plans – Without plans structures will fail to be effective Advanced planning in any sort of design can.
From Randomness to Probability Chapter 14. Dealing with Random Phenomena A random phenomenon is a situation in which we know what outcomes could happen,
By Rick Mercer with help from Kent Beck and Scott Ambler Java Review via Test Driven Development (TDD)
Test-Driven Development Eduard Miric ă. The problem.
1 Presentation Title Test-driven development (TDD) Overview David Wu.
2-1 By Rick Mercer with help from Kent Beck and Scott Ambler Java Review via Test Driven Development.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
(1) Test Driven Development Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
Unit Testing with FlexUnit
Stéphane Ducasse 1 Abstract Classes.
Google C++ Testing Framework Part 2: Assertion. Concepts A test case contains one or many tests. ◦ You should group your tests into test cases that reflect.
PHPUnit Julia Bondar IAPM23. Agenda What is PHPUnit How to write an automated test Writing and running tests with PHPUnit Advantages and disadvantages.
Statistics 16 Random Variables. Expected Value: Center A random variable assumes a value based on the outcome of a random event. –We use a capital letter,
Automated Testing with PHPUnit. How do you know your code works?
Developer Testing Tricks
Smalltalk Testing - SUnit
Logger, Assert and Invariants
Paul Ammann & Jeff Offutt
Verification and Testing
Testing UW CSE 160 Winter 2017.
Planning User stories are written.
Test Data Generators.
Johanna Rothman Create Technical Excellence Chapter 9
Testing UW CSE 160 Winter 2016.
Test-driven development (TDD)
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Introduction to Software Testing (2nd edition) Chapter 4 TDD Example
Test-Driven Development
TDD & ATDD 1/15/2019.
Testing Mutable Objects
An Example of Interacting Classes
EEC-492/693/793 iPhone Application Development
Algorithms and Problem Solving
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
Test-Driven Development
Presentation transcript:

Smalltalk Connections 1 Test Driven Development (TDD) Presented by Victor Goldberg, Ph.D.

Smalltalk Connections 2 The Nature of our Problem Then a miracle occurs Good work, but I think we need more detail right here.

Smalltalk Connections 3 What is Test Driven Development? It’s a practice that adds reliability to the development process.

Smalltalk Connections 4 Why is TDD important? Many projects fail because they lack a good testing methodology. It’s common sense, but it isn’t common practice. The sense of continuous reliability and success gives you a feeling of confidence in your code, which makes programming more fun.

Smalltalk Connections 5 How does it work?  Have a requirement. Let’s say “create a new random card, as for a card game”.  Think about what could be a reasonable test to verify compliance with the requirement.  Write the test before writing the code. Of course, the test will fail, and that’s ok.  Keep things simple.  Then, write only the minimally necessary code to make the test pass.  This is a process of discovery; as you identify possible improvements, refactor your code relentlessly to implement them.  Build, keep, and frequently run your cumulative collection of tests.

Smalltalk Connections 6 There are different kinds of tests Experiments (a.k.a. spikes), Acceptance tests, Code Behavior tests, and Development code TDD’s main functional testsrealm. We will also touch on experiments.

Smalltalk Connections 7 A Possible Initial TDD Test (in Smalltalk [ST]) testCardDrawnIsWithinRange | number | number := card draw numericalValue. self assert: ( number > 0 ) & ( number < 14 ). Local variable Object Action Getter – retrieves a result of the action Method Name

Smalltalk Connections 8 Fig 1. The same code in the ST browser. card is in red because the system doesn’t recognize such an object. self is an instance of the class TestCards. assert: is a message sent to self; its argument is a Boolean. TestCards is a child of TestCase, a class in the SUnit framework.

Smalltalk Connections 9 Fig 2. When run, the test identifies an error. The assertion didn’t have the opportunity to fail, because an error was identified before the assertion was applied.

Smalltalk Connections 10 Fig 3. The Card class and card instance are created. The new instance of Card is assigned to the variable card. (The Card class) (The card instance)

Smalltalk Connections 11 Fig 4. The test still identifies an error. The card instance doesn’t recognize the method #draw. Designing #draw requires some skill. We will develop the skill through an experiment.

Smalltalk Connections 12 Experiment Example in the Smalltalk Workspace r := Random new.frequency := Bag new."Variables typing" 1 to: do: [ :index | |result | result := (r next * 13) floor + 1. result >0 & result < 14 ifTrue: [ frequency add: result] ifFalse: [ ^ Dialog warn: 'Result out of range' ]. ]. ^ frequency contents. Fig. 5 The ST Workspace is like scratch paper, a place to experiment. The experiment here is to find whether our formula for random numbers is acceptable.

Fig 6. The results of running the code twice. The distribution of values is in the same range for each outcome, but different for each run. All are within [1, 13]. So, we are confident that our coding of the math is correct.

Smalltalk Connections 14 Fig 7. After the experiment we feel comfortable writing #draw. In #draw we assign the result of the calculation to the instance variable numericalValue

Smalltalk Connections 15 Fig 8. Now the test passes. In this case numericalValue is a getter, a message sent to the card object to retrieve the contents of the instance variable numericalValue.

Smalltalk Connections 16 TDD is fun!!! Passing the test (the green bar) is the feedback that makes it fun.

Smalltalk Connections 17 Summary

Smalltalk Connections 18 Summary (1) In TDD: Requirements drive the tests. Tests drive the development of the application code. No application code is written without writing a failing test first. Tests are collected in a suite and the suite is run frequently, like every time after code is written. Test and code are written in elementary increments. Refactoring is a continuous operation, and is supported by a passing battery of tests.

Smalltalk Connections 19 Summary (2) TDD is good because it: Reduces the number of bugs by orders of magnitude, Increases development speed, because less time is spent chasing bugs. Improves code quality because of the increased modularity, and continuous and relentless refactoring. Decreases maintenance costs because the code is easier to follow.

Smalltalk Connections 20 Summary (3) In addition to all its technical contributions to a project, Test Driven Development succeeds because …