SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
Not sure if I have to check out this problem
Or just wait for the customer feedback
How to Narrow Down What to Test
@ZsoltFabok
http://zsoltfabok.com/
#xp2013
http://xp2013.org/
by
Zsolt Fabok
2013-06-05
@ZsoltFabok
or
#xp2013
Exercise 0: Setup
Download putty.exe if you are using windows:
http://<host>:8080/xp2013/putty.exe
Log in (user, userpass):
ssh user@<host> -p 3022
Create your environment:
$ cd xp2013
$ mkdir <yourname>
$ cp -r arithmetic.expression.evaluator <yourname>
$ cd <yourname>/arithmetic.expression.evaluator
$ ant init
Check the source directory in your browser:
http://<host>:8080/xp2013/<yourname>
“I get paid for code that works, not for tests, so my
philosophy is to test as little as possible to reach a given
level of confidence (I suspect this level of confidence is
high compared to industry standards, but that could just
be hubris). If I don’t typically make a kind of mistake (like
setting the wrong variables in a constructor), I don’t test
for it. I do tend to make sense of test errors, so I’m extra
careful when I have logic with complicated conditionals.
When coding on a team, I modify my strategy to carefully
test code that we, collectively, tend to get wrong.”
Kent Beck - September 10, 2010
quote: http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests/153565#153565
I’d like to [re]start working on this
legacy application
My “where to start” list
#1 Determine which parts of
the code are really used
The good old Standish Group Study
7%
13%
16%19%
45%
Always
Often
Sometimes
Rarely
Never
The goal is to find those features which are
always or often used.
By studying coverage, access logs,
traces, web analytics, heat maps, etc.
Let’s have a look at the coverage
(using instrumented class files):
% cp jetty/cobertura.ser web.ser
% cp uploader/cobertura.ser ant.ser
% ant usage_coverage
usage_coverage:
[cobertura-merge] Cobertura: Loaded information on 12 classes.
[cobertura-merge] Cobertura: Loaded information on 11 classes.
[cobertura-merge] Cobertura: Saved information on 16 classes.
[cobertura-report] Cobertura: Loaded information on 16 classes.
[cobertura-report] Report time: 600ms
BUILD SUCCESSFUL
Total time: 2 seconds
Example #1: overview
Example #2: execution
not even
executed
Example #3: number of execution
.NET wins
FileBasedMetadata (usage)
FileHelper (usage)
Exercise 1: Usage
Run the application:
$ run.sh “4+3”
Turn on data collection:
$ ant instrument
$ vi run.sh
Run the application a couple of times:
$ run.sh “4+3”
Generate report:
$ ant usage_report
#2 Find out which parts of
the code change often
By checking how many times a file has
been committed into VCS:
% ./git_stat.sh
14, VerifierTask.java
13, index.jsp
11, FileBasedUserHome.java
11, FileBasedUser.java
11, FileBasedContentTracker.java
8, IntegrityCheckTask.java
7, MailSender.java
FileBasedMetadata (usage)
FileHelper (usage)
VerifierTask (changes)
index.jsp (changes)
FileBasedUserHome (changes)
Exercise 2: Have a beer (or
tea of coffee) :-)
#3 Determine which part of
the code changes data
Code review
“You have exactly 1 minute to explain to me
what that method does!”
FileBasedMetadata (usage)
FileHelper (usage, review)
VerifierTask (changes)
index.jsp (changes)
FileBasedUserHome (changes, review)
FileBasedContentTracker (review)
Exercise 3: Code Review
Check the code in the reports directory in your
browser:
http://<host>:8080/xp2013/<yourname>/.../target/
reports/src
#4 Determine where the code
is most likely going to fail
(e.g. with static code checkers)
PMD is not helpful at the moment,
but good to know about it
FileBasedMetadata (usage)
FileHelper (usage, review, bugs)
VerifierTask (changes)
index.jsp (changes)
FileBasedUserHome (changes, review)
FileBasedContentTracker (review, bugs)
HarversterTask (bugs)
FileBasedContentTracker.fsck() (crap4j)
FileBasedContentTracker.gc() (crap4j)
VerifierTask.execute() (crap4j)
Let’s order our list and
we are done!
FileBasedMetadata (usage)
FileHelper (usage, review, bugs)
VerifierTask (changes)
index.jsp (changes)
FileBasedUserHome (changes, review)
FileBasedContentTracker (review, bugs)
HarversterTask (bugs)
FileBasedContentTracker.fsck() (crap4j)
FileBasedContentTracker.gc() (crap4j)
VerifierTask.execute() (crap4j)
Exercise 4: Code Checkers
Check the reports directory in your browser:
http://<host>/xp2013/<yourname>/.../target/reports
Generate reports:
$ ant reports
Now we know where to start, and
now let’s talk about how to start.
Gaining 30% coverage in 2 minutes:
public class CheaterTest {
@Test
public void shouldIncreaseTheCoverage() {
HarvesterTask harvester = new HarvesterTask();
Project project = new Project();
project.setBaseDir(new File("."));
harvester.setProject(project);
harvester.setRepository("../repository");
harvester.setHistory("history");
harvester.setTemplate("templates");
harvester.execute();
}
}
Covered code != Tested code
So, you start with an assertion:
public class FileHelperTest {
@Test
public void shouldReturnTheContentOfAFile() throws IOException {
assertEquals("", FileHelper.getFileContent(null));
}
}
➡ The ‘assertEquals’ makes sure that your test actually
does something
➡ The ‘null’ parameter - along with the
NullPointerException - will show you where to continue
First test case is done:
public class FileHelperTest {
@Test
public void shouldReturnTheContentOfAFile() throws IOException {
File input = File.createTempFile("foo", "bar");
assertEquals("", FileHelper.getFileContent(input));
}
}
➡ Now the test is green, let’s continue with a more
meaningful test case
Now we have two test cases:
public class FileHelperTest {
@Test
public void shouldReturnTheContentOfAFile() throws IOException {
File input = File.createTempFile("foo", "bar");
assertEquals("", FileHelper.getFileContent(input));
}
@Test
public void shouldReturnTheContentOfAFile() throws IOException {
File input = File.createTempFile("foo", "bar");
new FileOutputStream(input).write("something".getBytes());
assertEquals("something", FileHelper.getFileContent(input));
}
}
➡ Test method names remains the same until the body is
filled properly
And we are done (assertion + coverage):
public class FileHelperTest {
private File input;
@Before
public void setUp() throws IOException {
input = File.createTempFile("foo", "bar");
}
@Test
public void shouldReturnAnEmptyStringForAnEmptyFile() throws IOException {
assertEquals("", FileHelper.getFileContent(input));
}
@Test
public void shouldReturnTheContentOfAFile() throws IOException {
setInputFileContent("something");
assertEquals("something", FileHelper.getFileContent(input));
}
private void setInputFileContent(String content) throws IOException {
new FileOutputStream(input).write("something".getBytes());
}
}
Exercise 5: Writing tests
Get test coverage (also runs tests):
$ ant cobertura
Run tests:
$ ant test
If you don’t want to write tests, you can find
examples in this folder:
samples
Well tested code
Well tested code everywhere
What about web applications?
(I’ll use a ruby on rails example, but the principles apply to other frameworks as well)
#2 Find out which parts of the code change
often (a.k.a VCS statistics)
#3 Determine which part of the code
changes data (a.k.a code review)
Points
are just the same.
and
A large variety of tools are available for:
#4 Determine where the code is most likely
going to fail (a.k.a static code checkers)
% gem install rails_best_practices
% rails_best_practices -html .
Everything is nice and straightforward
until now, but the last remaining point
is tricky:
#1 Determine which parts of the code
are really used (a.k.a. coverage)
We can have coverage data in Ruby on Rails, too:
~/Temp/repos/sample_app % gem install simplecov
~/Temp/repos/sample_app % cat script/rails
#!/usr/bin/env ruby
require 'simplecov'
SimpleCov.start do
add_group "Models", "app/models"
add_group "Controllers", "app/controllers"
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
# rest of the script/rails script
There is only one problem: the application
must be stopped in order to get the report,
which is not really efficient and user friendly.
Fortunately, we can use a metric called
‘funnel’:
1. This is a huge lost in visitors,
would be good to know why.
2. Users visit this page more
often than the other page.
Slides: http://zsoltfabok.com/speaking/
Code: https://github.com/ZsoltFabok/
arithmetic.expression.evaluator/tree/xp2013/
Thank you very much for your attention!
http://zsoltfabok.com/ @ZsoltFabok

Más contenido relacionado

La actualidad más candente

Integration test framework
Integration test frameworkIntegration test framework
Integration test frameworkIlya Medvedev
 
Client server part 12
Client server part 12Client server part 12
Client server part 12fadlihulopi
 
React mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche EheReact mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche Eheinovex GmbH
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctlyDror Helper
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 
Discussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsDiscussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsPVS-Studio
 
Interaction testing using mock objects
Interaction testing using mock objectsInteraction testing using mock objects
Interaction testing using mock objectsLim Chanmann
 
C Sharp Tutorial : C Sharp Exception
C Sharp Tutorial : C Sharp ExceptionC Sharp Tutorial : C Sharp Exception
C Sharp Tutorial : C Sharp ExceptionCourseing Online
 
Laporan tugas network programming
Laporan tugas network programmingLaporan tugas network programming
Laporan tugas network programmingRahmatHamdani2
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialJeff Smith
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingMax Kleiner
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APIcaswenson
 
Legacy Code Kata v3.0
Legacy Code Kata v3.0Legacy Code Kata v3.0
Legacy Code Kata v3.0William Munn
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsChristopher Batey
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Andrey Karpov
 
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech Talk
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech TalkHacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech Talk
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech TalkRed Hat Developers
 

La actualidad más candente (20)

Integration test framework
Integration test frameworkIntegration test framework
Integration test framework
 
Client server part 12
Client server part 12Client server part 12
Client server part 12
 
React mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche EheReact mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche Ehe
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Discussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsDiscussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source Components
 
Interaction testing using mock objects
Interaction testing using mock objectsInteraction testing using mock objects
Interaction testing using mock objects
 
C Sharp Tutorial : C Sharp Exception
C Sharp Tutorial : C Sharp ExceptionC Sharp Tutorial : C Sharp Exception
C Sharp Tutorial : C Sharp Exception
 
Laporan tugas network programming
Laporan tugas network programmingLaporan tugas network programming
Laporan tugas network programming
 
Programming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorialProgramming with ZooKeeper - A basic tutorial
Programming with ZooKeeper - A basic tutorial
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
SPARQLing cocktails
SPARQLing cocktailsSPARQLing cocktails
SPARQLing cocktails
 
Legacy Code Kata v3.0
Legacy Code Kata v3.0Legacy Code Kata v3.0
Legacy Code Kata v3.0
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Testing Terraform
Testing TerraformTesting Terraform
Testing Terraform
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra Applications
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech Talk
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech TalkHacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech Talk
Hacking the Mesh: Extending Istio with WebAssembly Modules | DevNation Tech Talk
 

Similar a [xp2013] Narrow Down What to Test

How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...Yevgeniy Brikman
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSPVS-Studio
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMSJustinHolt20
 
Monitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaMonitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaArvind Kumar G.S
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworksphanleson
 
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfKAI CHU CHUNG
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing Ran Levy
 
Watir Presentation Sumanth Krishna. A
Watir Presentation   Sumanth Krishna. AWatir Presentation   Sumanth Krishna. A
Watir Presentation Sumanth Krishna. ASumanth krishna
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging TechniquesWebStackAcademy
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellPVS-Studio
 
Grails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & FunctionalGrails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & Functional2Paths Solutions Ltd.
 

Similar a [xp2013] Narrow Down What to Test (20)

How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMS
 
Monitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaMonitoring using Prometheus and Grafana
Monitoring using Prometheus and Grafana
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Exploit Frameworks
Exploit FrameworksExploit Frameworks
Exploit Frameworks
 
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Jakarta struts
Jakarta strutsJakarta struts
Jakarta struts
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing
 
Watir Presentation Sumanth Krishna. A
Watir Presentation   Sumanth Krishna. AWatir Presentation   Sumanth Krishna. A
Watir Presentation Sumanth Krishna. A
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
Grails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & FunctionalGrails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & Functional
 

Más de Zsolt Fabok

Kanban visualisation
Kanban visualisationKanban visualisation
Kanban visualisationZsolt Fabok
 
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the TeamZsolt Fabok
 
[OOP 2014] Social Sciences Make a Difference
[OOP 2014] Social Sciences Make a Difference[OOP 2014] Social Sciences Make a Difference
[OOP 2014] Social Sciences Make a DifferenceZsolt Fabok
 
[Agile Adria Croatia 2014] The Road to a Fairly Predictable System
[Agile Adria Croatia 2014] The Road to a Fairly Predictable System[Agile Adria Croatia 2014] The Road to a Fairly Predictable System
[Agile Adria Croatia 2014] The Road to a Fairly Predictable SystemZsolt Fabok
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZsolt Fabok
 
Philosophies of Building the Workplace
Philosophies of Building the WorkplacePhilosophies of Building the Workplace
Philosophies of Building the WorkplaceZsolt Fabok
 
Agile, Lean UX is Coming
Agile, Lean UX is ComingAgile, Lean UX is Coming
Agile, Lean UX is ComingZsolt Fabok
 
The Road to a Fairly Predictable System
The Road to a Fairly Predictable SystemThe Road to a Fairly Predictable System
The Road to a Fairly Predictable SystemZsolt Fabok
 
Measure and Manage Flow in Practice
Measure and Manage Flow in PracticeMeasure and Manage Flow in Practice
Measure and Manage Flow in PracticeZsolt Fabok
 
Narrow Down What to Test
Narrow Down What to TestNarrow Down What to Test
Narrow Down What to TestZsolt Fabok
 
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingAchieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingZsolt Fabok
 
The Groundhog Day of a Team Leader
The Groundhog Day of a Team LeaderThe Groundhog Day of a Team Leader
The Groundhog Day of a Team LeaderZsolt Fabok
 
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...Zsolt Fabok
 
Targu Mures - Behind the Curtain: The Agile/Lean Way of Working
Targu Mures - Behind the Curtain: The Agile/Lean Way of WorkingTargu Mures - Behind the Curtain: The Agile/Lean Way of Working
Targu Mures - Behind the Curtain: The Agile/Lean Way of WorkingZsolt Fabok
 
Targu Mures - Measure and Manage Flow in Practice
Targu Mures - Measure and Manage Flow in PracticeTargu Mures - Measure and Manage Flow in Practice
Targu Mures - Measure and Manage Flow in PracticeZsolt Fabok
 
ACCU2012 - The Groundhog Day of a Team Leader
ACCU2012 - The Groundhog Day of a Team LeaderACCU2012 - The Groundhog Day of a Team Leader
ACCU2012 - The Groundhog Day of a Team LeaderZsolt Fabok
 
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingAchieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingZsolt Fabok
 
SPSE2012 - Measure and Manage Flow in Practice
SPSE2012 - Measure and Manage Flow in PracticeSPSE2012 - Measure and Manage Flow in Practice
SPSE2012 - Measure and Manage Flow in PracticeZsolt Fabok
 
Don't Fear Change, Let Change Fear You
Don't Fear Change, Let Change Fear YouDon't Fear Change, Let Change Fear You
Don't Fear Change, Let Change Fear YouZsolt Fabok
 
The Difficult Life of a Lean Team Leader
The Difficult Life of a Lean Team LeaderThe Difficult Life of a Lean Team Leader
The Difficult Life of a Lean Team LeaderZsolt Fabok
 

Más de Zsolt Fabok (20)

Kanban visualisation
Kanban visualisationKanban visualisation
Kanban visualisation
 
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team
[LKUK13] I Broke the WIP Limit Twice, and I'm Still on the Team
 
[OOP 2014] Social Sciences Make a Difference
[OOP 2014] Social Sciences Make a Difference[OOP 2014] Social Sciences Make a Difference
[OOP 2014] Social Sciences Make a Difference
 
[Agile Adria Croatia 2014] The Road to a Fairly Predictable System
[Agile Adria Croatia 2014] The Road to a Fairly Predictable System[Agile Adria Croatia 2014] The Road to a Fairly Predictable System
[Agile Adria Croatia 2014] The Road to a Fairly Predictable System
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Philosophies of Building the Workplace
Philosophies of Building the WorkplacePhilosophies of Building the Workplace
Philosophies of Building the Workplace
 
Agile, Lean UX is Coming
Agile, Lean UX is ComingAgile, Lean UX is Coming
Agile, Lean UX is Coming
 
The Road to a Fairly Predictable System
The Road to a Fairly Predictable SystemThe Road to a Fairly Predictable System
The Road to a Fairly Predictable System
 
Measure and Manage Flow in Practice
Measure and Manage Flow in PracticeMeasure and Manage Flow in Practice
Measure and Manage Flow in Practice
 
Narrow Down What to Test
Narrow Down What to TestNarrow Down What to Test
Narrow Down What to Test
 
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingAchieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
 
The Groundhog Day of a Team Leader
The Groundhog Day of a Team LeaderThe Groundhog Day of a Team Leader
The Groundhog Day of a Team Leader
 
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...
Bp Meetup - Achieving Maintenance Stabilisation with Agile, Kanban and Lean T...
 
Targu Mures - Behind the Curtain: The Agile/Lean Way of Working
Targu Mures - Behind the Curtain: The Agile/Lean Way of WorkingTargu Mures - Behind the Curtain: The Agile/Lean Way of Working
Targu Mures - Behind the Curtain: The Agile/Lean Way of Working
 
Targu Mures - Measure and Manage Flow in Practice
Targu Mures - Measure and Manage Flow in PracticeTargu Mures - Measure and Manage Flow in Practice
Targu Mures - Measure and Manage Flow in Practice
 
ACCU2012 - The Groundhog Day of a Team Leader
ACCU2012 - The Groundhog Day of a Team LeaderACCU2012 - The Groundhog Day of a Team Leader
ACCU2012 - The Groundhog Day of a Team Leader
 
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean ThinkingAchieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
Achieving Maintenance Stabilisation with Agile, Kanban and Lean Thinking
 
SPSE2012 - Measure and Manage Flow in Practice
SPSE2012 - Measure and Manage Flow in PracticeSPSE2012 - Measure and Manage Flow in Practice
SPSE2012 - Measure and Manage Flow in Practice
 
Don't Fear Change, Let Change Fear You
Don't Fear Change, Let Change Fear YouDon't Fear Change, Let Change Fear You
Don't Fear Change, Let Change Fear You
 
The Difficult Life of a Lean Team Leader
The Difficult Life of a Lean Team LeaderThe Difficult Life of a Lean Team Leader
The Difficult Life of a Lean Team Leader
 

Último

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Último (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

[xp2013] Narrow Down What to Test

  • 1. Not sure if I have to check out this problem Or just wait for the customer feedback How to Narrow Down What to Test @ZsoltFabok http://zsoltfabok.com/ #xp2013 http://xp2013.org/ by Zsolt Fabok 2013-06-05
  • 4. Download putty.exe if you are using windows: http://<host>:8080/xp2013/putty.exe Log in (user, userpass): ssh user@<host> -p 3022 Create your environment: $ cd xp2013 $ mkdir <yourname> $ cp -r arithmetic.expression.evaluator <yourname> $ cd <yourname>/arithmetic.expression.evaluator $ ant init
  • 5. Check the source directory in your browser: http://<host>:8080/xp2013/<yourname>
  • 6. “I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don’t typically make a kind of mistake (like setting the wrong variables in a constructor), I don’t test for it. I do tend to make sense of test errors, so I’m extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong.” Kent Beck - September 10, 2010 quote: http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests/153565#153565
  • 7. I’d like to [re]start working on this legacy application
  • 8. My “where to start” list
  • 9. #1 Determine which parts of the code are really used
  • 10. The good old Standish Group Study 7% 13% 16%19% 45% Always Often Sometimes Rarely Never
  • 11. The goal is to find those features which are always or often used. By studying coverage, access logs, traces, web analytics, heat maps, etc.
  • 12. Let’s have a look at the coverage (using instrumented class files): % cp jetty/cobertura.ser web.ser % cp uploader/cobertura.ser ant.ser % ant usage_coverage usage_coverage: [cobertura-merge] Cobertura: Loaded information on 12 classes. [cobertura-merge] Cobertura: Loaded information on 11 classes. [cobertura-merge] Cobertura: Saved information on 16 classes. [cobertura-report] Cobertura: Loaded information on 16 classes. [cobertura-report] Report time: 600ms BUILD SUCCESSFUL Total time: 2 seconds
  • 14. Example #2: execution not even executed
  • 15. Example #3: number of execution .NET wins
  • 18. Run the application: $ run.sh “4+3” Turn on data collection: $ ant instrument $ vi run.sh Run the application a couple of times: $ run.sh “4+3” Generate report: $ ant usage_report
  • 19. #2 Find out which parts of the code change often
  • 20. By checking how many times a file has been committed into VCS: % ./git_stat.sh 14, VerifierTask.java 13, index.jsp 11, FileBasedUserHome.java 11, FileBasedUser.java 11, FileBasedContentTracker.java 8, IntegrityCheckTask.java 7, MailSender.java
  • 21. FileBasedMetadata (usage) FileHelper (usage) VerifierTask (changes) index.jsp (changes) FileBasedUserHome (changes)
  • 22. Exercise 2: Have a beer (or tea of coffee) :-)
  • 23. #3 Determine which part of the code changes data
  • 24. Code review “You have exactly 1 minute to explain to me what that method does!”
  • 25. FileBasedMetadata (usage) FileHelper (usage, review) VerifierTask (changes) index.jsp (changes) FileBasedUserHome (changes, review) FileBasedContentTracker (review)
  • 27. Check the code in the reports directory in your browser: http://<host>:8080/xp2013/<yourname>/.../target/ reports/src
  • 28. #4 Determine where the code is most likely going to fail (e.g. with static code checkers)
  • 29.
  • 30. PMD is not helpful at the moment, but good to know about it
  • 31.
  • 32. FileBasedMetadata (usage) FileHelper (usage, review, bugs) VerifierTask (changes) index.jsp (changes) FileBasedUserHome (changes, review) FileBasedContentTracker (review, bugs) HarversterTask (bugs) FileBasedContentTracker.fsck() (crap4j) FileBasedContentTracker.gc() (crap4j) VerifierTask.execute() (crap4j)
  • 33. Let’s order our list and we are done!
  • 34. FileBasedMetadata (usage) FileHelper (usage, review, bugs) VerifierTask (changes) index.jsp (changes) FileBasedUserHome (changes, review) FileBasedContentTracker (review, bugs) HarversterTask (bugs) FileBasedContentTracker.fsck() (crap4j) FileBasedContentTracker.gc() (crap4j) VerifierTask.execute() (crap4j)
  • 35. Exercise 4: Code Checkers
  • 36. Check the reports directory in your browser: http://<host>/xp2013/<yourname>/.../target/reports Generate reports: $ ant reports
  • 37. Now we know where to start, and now let’s talk about how to start.
  • 38. Gaining 30% coverage in 2 minutes: public class CheaterTest { @Test public void shouldIncreaseTheCoverage() { HarvesterTask harvester = new HarvesterTask(); Project project = new Project(); project.setBaseDir(new File(".")); harvester.setProject(project); harvester.setRepository("../repository"); harvester.setHistory("history"); harvester.setTemplate("templates"); harvester.execute(); } } Covered code != Tested code
  • 39. So, you start with an assertion: public class FileHelperTest { @Test public void shouldReturnTheContentOfAFile() throws IOException { assertEquals("", FileHelper.getFileContent(null)); } } ➡ The ‘assertEquals’ makes sure that your test actually does something ➡ The ‘null’ parameter - along with the NullPointerException - will show you where to continue
  • 40. First test case is done: public class FileHelperTest { @Test public void shouldReturnTheContentOfAFile() throws IOException { File input = File.createTempFile("foo", "bar"); assertEquals("", FileHelper.getFileContent(input)); } } ➡ Now the test is green, let’s continue with a more meaningful test case
  • 41. Now we have two test cases: public class FileHelperTest { @Test public void shouldReturnTheContentOfAFile() throws IOException { File input = File.createTempFile("foo", "bar"); assertEquals("", FileHelper.getFileContent(input)); } @Test public void shouldReturnTheContentOfAFile() throws IOException { File input = File.createTempFile("foo", "bar"); new FileOutputStream(input).write("something".getBytes()); assertEquals("something", FileHelper.getFileContent(input)); } } ➡ Test method names remains the same until the body is filled properly
  • 42. And we are done (assertion + coverage): public class FileHelperTest { private File input; @Before public void setUp() throws IOException { input = File.createTempFile("foo", "bar"); } @Test public void shouldReturnAnEmptyStringForAnEmptyFile() throws IOException { assertEquals("", FileHelper.getFileContent(input)); } @Test public void shouldReturnTheContentOfAFile() throws IOException { setInputFileContent("something"); assertEquals("something", FileHelper.getFileContent(input)); } private void setInputFileContent(String content) throws IOException { new FileOutputStream(input).write("something".getBytes()); } }
  • 44. Get test coverage (also runs tests): $ ant cobertura Run tests: $ ant test If you don’t want to write tests, you can find examples in this folder: samples
  • 45. Well tested code Well tested code everywhere
  • 46. What about web applications? (I’ll use a ruby on rails example, but the principles apply to other frameworks as well)
  • 47. #2 Find out which parts of the code change often (a.k.a VCS statistics) #3 Determine which part of the code changes data (a.k.a code review) Points are just the same. and
  • 48. A large variety of tools are available for: #4 Determine where the code is most likely going to fail (a.k.a static code checkers)
  • 49. % gem install rails_best_practices % rails_best_practices -html .
  • 50.
  • 51.
  • 52. Everything is nice and straightforward until now, but the last remaining point is tricky: #1 Determine which parts of the code are really used (a.k.a. coverage)
  • 53. We can have coverage data in Ruby on Rails, too: ~/Temp/repos/sample_app % gem install simplecov ~/Temp/repos/sample_app % cat script/rails #!/usr/bin/env ruby require 'simplecov' SimpleCov.start do add_group "Models", "app/models" add_group "Controllers", "app/controllers" end APP_PATH = File.expand_path('../../config/application', __FILE__) # rest of the script/rails script
  • 54.
  • 55. There is only one problem: the application must be stopped in order to get the report, which is not really efficient and user friendly.
  • 56. Fortunately, we can use a metric called ‘funnel’:
  • 57.
  • 58. 1. This is a huge lost in visitors, would be good to know why. 2. Users visit this page more often than the other page.
  • 60. Thank you very much for your attention! http://zsoltfabok.com/ @ZsoltFabok