SlideShare uma empresa Scribd logo
1 de 50
Mocking with JMockit Mario Peshev DevriX CTO, SCJP Consultant, Trainer http://www.linkedin.com/in/mpeshev http://devrix.com
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is Mocking ,[object Object],[object Object],[object Object]
What is Mocking (2) ,[object Object],[object Object]
Mocking Scheme DB Server Web Server Application with dependencies MOCKED
Why mock? ,[object Object],[object Object],[object Object]
Mocking advantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How does mocking work ,[object Object],[object Object],[object Object],[object Object],[object Object]
Proxy based ,[object Object],[object Object],[object Object],[object Object]
Proxy based (2) ,[object Object],[object Object],[object Object]
Class loader mapping ,[object Object],[object Object],[object Object]
Instrumentation API ,[object Object],[object Object],[object Object],[object Object]
Instrumentation API (2)
Remapping example ,[object Object],[object Object],[object Object]
JMockit
JMockit ,[object Object],[object Object],[object Object],[object Object]
JMockit Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JMockit vs. the World ,[object Object],[object Object],[object Object]
JMockit inside
Expectations API ,[object Object],[object Object],[object Object],[object Object]
Expectations API (2) ,[object Object],new Expectations() { ClassToBeMocked mock;  {  …  } }
Expectations API (3) ,[object Object],[object Object],[object Object]
Expectations API (4) ,[object Object],[object Object],[object Object],[object Object]
Expectations API (5) ,[object Object],[object Object],[object Object]
Expectations Sample public class MockNoInterfaceClassTest {  static class User {  String name() {  return "joe";  }  }  @Mocked  User user;  …
Expectations Sample (2) … @Test  public void mockNoInterfaceFinalClass()  {  new Expectations() {  {  user.name();  returns("fred");  }};  assertEquals("fred", user.name());  }  }
Verifications API ,[object Object],[object Object],[object Object]
Verification API (2) ,[object Object],[object Object]
Verification Demo static class UserService { void populateUser() { User user = new User(); user.setName("fred"); user.setAge(31); } } @Mocked User user; …
Verification Demo (2) … @Test public void verifyInternalMethods() { new UserService().populateUser(); new FullVerificationsInOrder() { { User user = new User(); user.setName("fred"); user.setAge(withAny(1)); } }; }
Verification Types ,[object Object],[object Object],[object Object],[object Object],[object Object]
JMockit test method template ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JMockit Mockups ,[object Object],[object Object],[object Object],[object Object]
State-oriented mocking ,[object Object],[object Object],[object Object]
Annotations Demo @Test public void mockSystemNanoTime() { new MockUp<System>() { @Mock @SuppressWarnings(&quot;unused&quot;) long nanoTime() { return 0L; } }; assertSame(0L, System.nanoTime()); }
JMockit Coverage ,[object Object],[object Object],[object Object],[object Object]
JMockit Coverage (2) ,[object Object],[object Object],[object Object],[object Object]
Coverage Report
Hibernate Emulation ,[object Object],[object Object],[object Object]
JMockit installation ,[object Object],[object Object],[object Object],[object Object]
JMockit with TestNG ,[object Object],[object Object],[object Object]
Running JMockit with TestNG Eclipse Demo
@Mocked and @Injectable ,[object Object],[object Object],[object Object],[object Object]
JMockit vs. PowerMock ,[object Object],[object Object],[object Object],[object Object]
JMockit vs. PowerMock (2) ,[object Object],[object Object],[object Object]
JMockit vs. Mockito ,[object Object],[object Object],[object Object]
JMockit vs. Mockito (2) ,[object Object],[object Object],[object Object]
JMockit vs. Mockito (3) ,[object Object],[object Object]
Questions?
DevriX Ltd ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://devrix.com

Mais conteúdo relacionado

Mais procurados

An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit TestingJoe Tremblay
 
05 junit
05 junit05 junit
05 junitmha4
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Edureka!
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test frameworkAbner Chih Yi Huang
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testingikhwanhayat
 
Junit mockito and PowerMock in Java
Junit mockito and  PowerMock in JavaJunit mockito and  PowerMock in Java
Junit mockito and PowerMock in JavaAnkur Maheshwari
 

Mais procurados (20)

An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
Using Mockito
Using MockitoUsing Mockito
Using Mockito
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
05 junit
05 junit05 junit
05 junit
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 
Karate DSL
Karate DSLKarate DSL
Karate DSL
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Google test training
Google test trainingGoogle test training
Google test training
 
Junit
JunitJunit
Junit
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Junit 4.0
Junit 4.0Junit 4.0
Junit 4.0
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
Junit mockito and PowerMock in Java
Junit mockito and  PowerMock in JavaJunit mockito and  PowerMock in Java
Junit mockito and PowerMock in Java
 

Destaque

Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock TutorialSbin m
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practicesnickokiss
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
China: City kills 5,000 dogs to curb rabies outbreak
China: City kills 5,000 dogs to curb rabies outbreakChina: City kills 5,000 dogs to curb rabies outbreak
China: City kills 5,000 dogs to curb rabies outbreakdogtrainingalways16
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Qualityguest268ee8
 
Getting started with jMock
Getting started with jMockGetting started with jMock
Getting started with jMockayman diab
 
Junit y Jmock
Junit y JmockJunit y Jmock
Junit y Jmockkaolong
 
Automation testing & Unit testing
Automation testing & Unit testingAutomation testing & Unit testing
Automation testing & Unit testingKapil Rajpurohit
 
Mocking in Python
Mocking in PythonMocking in Python
Mocking in PythonExcella
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanQA or the Highway
 
Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockitoMathieu Carbou
 

Destaque (18)

Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Unit testing with java
Unit testing with javaUnit testing with java
Unit testing with java
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock Tutorial
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
China: City kills 5,000 dogs to curb rabies outbreak
China: City kills 5,000 dogs to curb rabies outbreakChina: City kills 5,000 dogs to curb rabies outbreak
China: City kills 5,000 dogs to curb rabies outbreak
 
Test Case Potency Assessment
Test Case Potency AssessmentTest Case Potency Assessment
Test Case Potency Assessment
 
Mockito tutorial for beginners
Mockito tutorial for beginnersMockito tutorial for beginners
Mockito tutorial for beginners
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Quality
 
Getting started with jMock
Getting started with jMockGetting started with jMock
Getting started with jMock
 
Junit y Jmock
Junit y JmockJunit y Jmock
Junit y Jmock
 
Jmock testing
Jmock testingJmock testing
Jmock testing
 
EasyMock for Java
EasyMock for JavaEasyMock for Java
EasyMock for Java
 
Automation testing & Unit testing
Automation testing & Unit testingAutomation testing & Unit testing
Automation testing & Unit testing
 
Mocking in Python
Mocking in PythonMocking in Python
Mocking in Python
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey Shannahan
 
Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockito
 

Semelhante a JMockit Framework Overview

An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAhmed Ehab AbdulAziz
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaDenilson Nastacio
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocksguillaumecarre
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
System verilog important
System verilog importantSystem verilog important
System verilog importantelumalai7
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3AtakanAral
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docxssuser1c8ca21
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Spring training
Spring trainingSpring training
Spring trainingTechFerry
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSam Brannen
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringromanovfedor
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration TestingPaul Churchward
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]Mohamed Abdeen
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019Paulo Clavijo
 

Semelhante a JMockit Framework Overview (20)

An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
Mocking with Mockito
Mocking with MockitoMocking with Mockito
Mocking with Mockito
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for Java
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Testing w-mocks
Testing w-mocksTesting w-mocks
Testing w-mocks
 
Mule ctf
Mule  ctfMule  ctf
Mule ctf
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Test api
Test apiTest api
Test api
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docx
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Spring training
Spring trainingSpring training
Spring training
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discovering
 
Intro To Unit and integration Testing
Intro To Unit and integration TestingIntro To Unit and integration Testing
Intro To Unit and integration Testing
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
 

Mais de Mario Peshev

Why Does an eCommerce Store Cost 200 to 100K And More?
Why Does an eCommerce Store Cost 200 to 100K And More?Why Does an eCommerce Store Cost 200 to 100K And More?
Why Does an eCommerce Store Cost 200 to 100K And More?Mario Peshev
 
Management Decision Making Process
Management Decision Making ProcessManagement Decision Making Process
Management Decision Making ProcessMario Peshev
 
The Future Of WordPress In 2020
The Future Of WordPress In 2020The Future Of WordPress In 2020
The Future Of WordPress In 2020Mario Peshev
 
What Makes PHP An Awesome Language
What Makes PHP An Awesome LanguageWhat Makes PHP An Awesome Language
What Makes PHP An Awesome LanguageMario Peshev
 
Top 6 Business Tips for October 2019
Top 6 Business Tips for October 2019Top 6 Business Tips for October 2019
Top 6 Business Tips for October 2019Mario Peshev
 
The Future of WordPress And WooCommerce
The Future of WordPress And WooCommerceThe Future of WordPress And WooCommerce
The Future of WordPress And WooCommerceMario Peshev
 
Tips for Successful WordPress Enterprise Projects
Tips for Successful WordPress Enterprise ProjectsTips for Successful WordPress Enterprise Projects
Tips for Successful WordPress Enterprise ProjectsMario Peshev
 
WordPress Architecture for Tech-Savvy Managers
WordPress Architecture for Tech-Savvy ManagersWordPress Architecture for Tech-Savvy Managers
WordPress Architecture for Tech-Savvy ManagersMario Peshev
 
Business and Monetization Opportunities for Developers
Business and Monetization Opportunities for DevelopersBusiness and Monetization Opportunities for Developers
Business and Monetization Opportunities for DevelopersMario Peshev
 
Building SaaS with WordPress - WordCamp Netherlands 2016
Building SaaS with WordPress - WordCamp Netherlands 2016Building SaaS with WordPress - WordCamp Netherlands 2016
Building SaaS with WordPress - WordCamp Netherlands 2016Mario Peshev
 
WordPress Code Architecture
WordPress Code ArchitectureWordPress Code Architecture
WordPress Code ArchitectureMario Peshev
 
Virtual Company - Go Limitless
Virtual Company - Go LimitlessVirtual Company - Go Limitless
Virtual Company - Go LimitlessMario Peshev
 
Debugging WordPress
Debugging WordPressDebugging WordPress
Debugging WordPressMario Peshev
 
Platforms based on WordPress
Platforms based on WordPressPlatforms based on WordPress
Platforms based on WordPressMario Peshev
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers TeamMario Peshev
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPressMario Peshev
 
Contributing to WordPress
Contributing to WordPressContributing to WordPress
Contributing to WordPressMario Peshev
 
Start Your Website for Free!
Start Your Website for Free!Start Your Website for Free!
Start Your Website for Free!Mario Peshev
 
Choosing a WordPress Theme
Choosing a WordPress ThemeChoosing a WordPress Theme
Choosing a WordPress ThemeMario Peshev
 

Mais de Mario Peshev (20)

Why Does an eCommerce Store Cost 200 to 100K And More?
Why Does an eCommerce Store Cost 200 to 100K And More?Why Does an eCommerce Store Cost 200 to 100K And More?
Why Does an eCommerce Store Cost 200 to 100K And More?
 
Management Decision Making Process
Management Decision Making ProcessManagement Decision Making Process
Management Decision Making Process
 
The Future Of WordPress In 2020
The Future Of WordPress In 2020The Future Of WordPress In 2020
The Future Of WordPress In 2020
 
What Makes PHP An Awesome Language
What Makes PHP An Awesome LanguageWhat Makes PHP An Awesome Language
What Makes PHP An Awesome Language
 
Top 6 Business Tips for October 2019
Top 6 Business Tips for October 2019Top 6 Business Tips for October 2019
Top 6 Business Tips for October 2019
 
The Future of WordPress And WooCommerce
The Future of WordPress And WooCommerceThe Future of WordPress And WooCommerce
The Future of WordPress And WooCommerce
 
Tips for Successful WordPress Enterprise Projects
Tips for Successful WordPress Enterprise ProjectsTips for Successful WordPress Enterprise Projects
Tips for Successful WordPress Enterprise Projects
 
WordPress Architecture for Tech-Savvy Managers
WordPress Architecture for Tech-Savvy ManagersWordPress Architecture for Tech-Savvy Managers
WordPress Architecture for Tech-Savvy Managers
 
Business and Monetization Opportunities for Developers
Business and Monetization Opportunities for DevelopersBusiness and Monetization Opportunities for Developers
Business and Monetization Opportunities for Developers
 
Building SaaS with WordPress - WordCamp Netherlands 2016
Building SaaS with WordPress - WordCamp Netherlands 2016Building SaaS with WordPress - WordCamp Netherlands 2016
Building SaaS with WordPress - WordCamp Netherlands 2016
 
WordPress Code Architecture
WordPress Code ArchitectureWordPress Code Architecture
WordPress Code Architecture
 
Virtual Company - Go Limitless
Virtual Company - Go LimitlessVirtual Company - Go Limitless
Virtual Company - Go Limitless
 
Debugging WordPress
Debugging WordPressDebugging WordPress
Debugging WordPress
 
Platforms based on WordPress
Platforms based on WordPressPlatforms based on WordPress
Platforms based on WordPress
 
WordPress Theme Reviewers Team
WordPress Theme Reviewers TeamWordPress Theme Reviewers Team
WordPress Theme Reviewers Team
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
 
Contributing to WordPress
Contributing to WordPressContributing to WordPress
Contributing to WordPress
 
Start Your Website for Free!
Start Your Website for Free!Start Your Website for Free!
Start Your Website for Free!
 
Choosing a WordPress Theme
Choosing a WordPress ThemeChoosing a WordPress Theme
Choosing a WordPress Theme
 
Sass in 5
Sass in 5Sass in 5
Sass in 5
 

Último

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Último (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

JMockit Framework Overview

  • 1. Mocking with JMockit Mario Peshev DevriX CTO, SCJP Consultant, Trainer http://www.linkedin.com/in/mpeshev http://devrix.com
  • 2.
  • 3.
  • 4.
  • 5. Mocking Scheme DB Server Web Server Application with dependencies MOCKED
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 14.
  • 16.
  • 17.
  • 18.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Expectations Sample public class MockNoInterfaceClassTest { static class User { String name() { return &quot;joe&quot;; } } @Mocked User user; …
  • 26. Expectations Sample (2) … @Test public void mockNoInterfaceFinalClass() { new Expectations() { { user.name(); returns(&quot;fred&quot;); }}; assertEquals(&quot;fred&quot;, user.name()); } }
  • 27.
  • 28.
  • 29. Verification Demo static class UserService { void populateUser() { User user = new User(); user.setName(&quot;fred&quot;); user.setAge(31); } } @Mocked User user; …
  • 30. Verification Demo (2) … @Test public void verifyInternalMethods() { new UserService().populateUser(); new FullVerificationsInOrder() { { User user = new User(); user.setName(&quot;fred&quot;); user.setAge(withAny(1)); } }; }
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Annotations Demo @Test public void mockSystemNanoTime() { new MockUp<System>() { @Mock @SuppressWarnings(&quot;unused&quot;) long nanoTime() { return 0L; } }; assertSame(0L, System.nanoTime()); }
  • 36.
  • 37.
  • 39.
  • 40.
  • 41.
  • 42. Running JMockit with TestNG Eclipse Demo
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 50.