SlideShare a Scribd company logo
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java
Unit Testing in Java

More Related Content

PDF
Need(le) for Speed - Effective Unit Testing for Java EE
PPT
Unit testing with java
PPT
Unit testing with java
PDF
Sample Chapter of Practical Unit Testing with TestNG and Mockito
PPT
Software testing basics and its types
PPTX
Principles and patterns for test driven development
PPT
Unit testing
PDF
Test driven development - JUnit basics and best practices
Need(le) for Speed - Effective Unit Testing for Java EE
Unit testing with java
Unit testing with java
Sample Chapter of Practical Unit Testing with TestNG and Mockito
Software testing basics and its types
Principles and patterns for test driven development
Unit testing
Test driven development - JUnit basics and best practices

What's hot (20)

PDF
2013 DevFest Vienna - Bad Tests, Good Tests
PPTX
JUnit- A Unit Testing Framework
PDF
Unit testing best practices
PDF
GeeCON 2012 Bad Tests, Good Tests
PDF
Confitura 2012 Bad Tests, Good Tests
PPTX
PPTX
Best practices unit testing
PDF
Unit testing best practices with JUnit
PDF
Oh so you test? - A guide to testing on Android from Unit to Mutation
PPTX
Unit Testing in Java
PPTX
Dev labs alliance top 20 testng interview questions for sdet
PDF
Unit testing with JUnit
PPTX
Thread & concurrancy
PPTX
JUNit Presentation
PPTX
The Best Pairwise Testing Tool / Best Orthogonal Array Tool Just Got Better
PPSX
PDF
Unit Test in Ruby on Rails by Minitest
PDF
PPT
Simple Unit Testing With Netbeans 6.1
PDF
Workshop unit test
2013 DevFest Vienna - Bad Tests, Good Tests
JUnit- A Unit Testing Framework
Unit testing best practices
GeeCON 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good Tests
Best practices unit testing
Unit testing best practices with JUnit
Oh so you test? - A guide to testing on Android from Unit to Mutation
Unit Testing in Java
Dev labs alliance top 20 testng interview questions for sdet
Unit testing with JUnit
Thread & concurrancy
JUNit Presentation
The Best Pairwise Testing Tool / Best Orthogonal Array Tool Just Got Better
Unit Test in Ruby on Rails by Minitest
Simple Unit Testing With Netbeans 6.1
Workshop unit test
Ad

Similar to Unit Testing in Java (20)

PDF
Pivotal Labs Open View Presentation Quality Assurance And Developer Testing
PDF
Just Java2007 - Daniel Wildt - Tools For Java Test Automation
PDF
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
PDF
What's software testing
PDF
Agile Java Testing With Open Source Frameworks
PDF
Groovy Testing Aug2009
PPTX
Database Unit Testing Made Easy with VSTS
PDF
DevDay 2016: Dave Farley - Acceptance testing for continuous delivery
PDF
ICTSS 2010 - Iterative Software Testing Process for Scrum and Waterfall Projects
PPTX
Test it! Unit, mocking and in-container Meet Arquillian!
PDF
Testing artifacts test cases
PPTX
Introduction to JUnit
ZIP
Test Driven Development
PDF
Groovy Testing Sep2009
PDF
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
PPTX
Lecture (Software Testing).pptx
PPTX
[DSBW Spring 2009] Unit 09: Web Testing
ZIP
Test
PPT
Test Automation Principles
Pivotal Labs Open View Presentation Quality Assurance And Developer Testing
Just Java2007 - Daniel Wildt - Tools For Java Test Automation
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
What's software testing
Agile Java Testing With Open Source Frameworks
Groovy Testing Aug2009
Database Unit Testing Made Easy with VSTS
DevDay 2016: Dave Farley - Acceptance testing for continuous delivery
ICTSS 2010 - Iterative Software Testing Process for Scrum and Waterfall Projects
Test it! Unit, mocking and in-container Meet Arquillian!
Testing artifacts test cases
Introduction to JUnit
Test Driven Development
Groovy Testing Sep2009
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Lecture (Software Testing).pptx
[DSBW Spring 2009] Unit 09: Web Testing
Test
Test Automation Principles
Ad

More from guy_davis (11)

PPT
Adopting Scrum and Agile
ZIP
Pragmatic Programmer
ZIP
Content Caching with Rails
ZIP
Agile Software Development Methodologies
ZIP
Project Monitoring and Control
ZIP
The Human Side of Software Development
ZIP
Adapter Design Pattern
ZIP
Software Quality Plan
ZIP
Unified Process
ZIP
Software Configuration Management
ZIP
Quality Function Deployment
Adopting Scrum and Agile
Pragmatic Programmer
Content Caching with Rails
Agile Software Development Methodologies
Project Monitoring and Control
The Human Side of Software Development
Adapter Design Pattern
Software Quality Plan
Unified Process
Software Configuration Management
Quality Function Deployment

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation theory and applications.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Modernizing your data center with Dell and AMD
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
“AI and Expert System Decision Support & Business Intelligence Systems”
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Understanding_Digital_Forensics_Presentation.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation theory and applications.pdf
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
Modernizing your data center with Dell and AMD
Cloud computing and distributed systems.
KodekX | Application Modernization Development
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx

Editor's Notes

  • #5: Automate tests: Cost not proportional to number of test runs like manual is More repeatable and less error-prone More fun and more likely to happen Goal of testing is to prevent defects, not find as many as possible. Root-cause analysis, fix the source of the problem.
  • #7: Mention how I always mix up the TestCase with a test case which is a certain scenario.
  • #8: Show the test results links for branches. Show Cobertura report.
  • #9: Show LoadModel test case Question: What happened to Error outcome from JUnit?
  • #10: Can either make static Assert.assertFoo() calls or use a static import to shorten this down. Show example of exception assertion in DVAdapterTest class.
  • #14: Expected objects: don’t compare pointX and pointY variables, just compare Point (object) Guard assertion: assertNotNull(collection) before asserting about its contents Custom assert: assertExactlyOneChildNode(node); created during test refactoring
  • #15: Clean Slate: watch out for code duplication Standard: brittleness from dependence on external data Shared: test run wars, interactions between tests, unrepeatable tests, example is our DV_TEST database
  • #18: A mock object fills the role of the real dependency by acting just like it.
  • #19: A mock object fills the role of the real dependency by acting just like it.
  • #20: A mock object fills the role of the real dependency by acting just like it.
  • #21: A mock object fills the role of the real dependency by acting just like it.
  • #22: A mock object fills the role of the real dependency by acting just like it.
  • #23: A mock object fills the role of the real dependency by acting just like it.
  • #24: Install Stub into SUT by: Passing as argument Passing as constructor argument Set explicitly with setter method Set in the environment (preferences, system property, JNDI) Discuss Active versus Passive stubs (Active stubs participate in the verification)
  • #25: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #26: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #27: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #28: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #29: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #30: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #31: Real component: Talk about DBUnit and embedded databases like HSQL for Merge tests. Mock object: Show MockRunner objects in LoadModel test for working JDBC. Mention that mock objects don’t need to be created by hand. Projects like EasyMock, jMock, and MockMaker can auto-generate.
  • #32: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #33: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #34: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #35: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #36: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #37: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #38: Talk about how much setup some tests require. Then show the answer: separation of concerns Then ask when should we test?
  • #39: See section 11 page 7 last slide for reasons.
  • #40: Mention that this can be hard as the original code wasn’t written with testability in mind. Likely it is highly coupled and not cohesive. Normally, you will need to iterate around the “write tests & refactor” loop until you have decent coverage.
  • #41: Show LoadModelTest for the Mockrunner example. Show AbstractPreferencesTestCase for the DBUnit.