Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

0

Share

Download to read offline

Mockito tutorial for beginners

Download to read offline

Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn how to write great unit tests with Mockito and JUnit. You take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency.
Mockito

Step 01 : Set up an Eclipse Project with JUnit and Mockito frameworks. First Green Bar.
Step 02 : Example to start understanding why we need mocks.
Step 03 : What is a stub? Create an unit test using Stub? Disadvantages of Stubs.
Step 04 : Your first Mockito code! Hurrah!!! Lets use Mockito to mock TodoService.
Step 05 : Stubbing variations with Mockito. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions.
Step 06 : Introduction to BDD. Given When Then. BDD Mockito Syntax.
Step 07 : How to verify calls on a mock? Verify how many times a method is called. We will add deleteTodo method to the TodoService.
Step 08 : How to capture an argument which is passed to a mock?
Step 09 : Hamcrest Matchers.
Step 10 : Let's simplify things with Mockito Annotations. @Mock, @InjectMocks, @RunWith(MockitoJUnitRunner.class), @Captor
Step 11 : JUnit Rules. Using MockitoJUnit.rule() instead of @RunWith(MockitoJUnitRunner.class).
Step 12 : Real world Example with Spring
Step 13 : What is a spy? How to spy with Mockito?
Step 14 : Some Theory : Why does Mockito not allow stubbing final and private methods?
Step 15 : Using PowerMock and Mockito to mock a Static Method.
Step 16 : Using PowerMock and Mockito to invoke a private Method.
Step 17 : Using PowerMock and Mockito to mock a constructor.
Step 18 : Good Unit Tests.


JUnit

Step 01 : Need for Unit Testing
Step 02 : Setting up your First JUnit
Step 03 : First Successful JUnit. Green Bar and assertEquals
Step 04 : Refactoring Your First JUnit Test
Step 05 : Second JUnit Example assertTrue and assertFalse
Step 06 : @Before @After
Step 07 : @BeforeClass @AfterClass
Step 08 : Comparing Arrays in JUnit Tests
Step 09 : Testing Exceptions in JUnit Tests
Step 10 : Testing Performance in JUnit Tests
Step 11 : Parameterized Tests
Step 12 : Organize JUnits into Suites

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Mockito tutorial for beginners

  1. 1. Mockito Tutorial
  2. 2. 2
  3. 3. 3
  4. 4. 4
  5. 5. 5
  6. 6. 6
  7. 7. 7
  8. 8. 8
  9. 9. 9
  10. 10. 10
  11. 11. 11
  12. 12. 12 GITHUB : https://github.com/in28minutes UDEMY : https://www.udemy.com/user/in28minutes/ YOUTUBE : https://www.youtube.com/rithustutorials Java EE Made Easy https://www.udemy.com/java-ee-design-patterns-architecture-and-frameworks/?couponCode=EEPATTERNS-PDF-1 Spring MVC – 25 Steps https://www.udemy.com/spring-mvc-tutorial-for-beginners-step-by-step/?couponCode=SPRNGMVC-PDF-1 JSP Servlets – 25 Steps https://www.udemy.com/learn-java-servlets-and-jsp-web-application-in-25-steps/?couponCode=JSPSRVLT-PDF-1 Maven https://www.udemy.com/learn-maven-java-dependency-management-in-20-steps/?couponCode=MAVEN-PDF-1 C Puzzles https://www.udemy.com/c-puzzles-for-beginners/?couponCode=CPUZZLES-PDF-1 Java Interview Guide https://gumroad.com/l/JavaInterviewGuide/website
  13. 13. 13 Free Courses https://www.udemy.com/eclipse-java-tutorial-for-beginners/ https://www.udemy.com/spring-tutorial-for-beginners/ https://www.udemy.com/junit-tutorial-for-beginners-with-java-examples/ https://www.youtube.com/watch?v=0jjNjXcYmAU
  14. 14. 14 Visit www.in28minutes.com for more..

Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn how to write great unit tests with Mockito and JUnit. You take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency. Mockito Step 01 : Set up an Eclipse Project with JUnit and Mockito frameworks. First Green Bar. Step 02 : Example to start understanding why we need mocks. Step 03 : What is a stub? Create an unit test using Stub? Disadvantages of Stubs. Step 04 : Your first Mockito code! Hurrah!!! Lets use Mockito to mock TodoService. Step 05 : Stubbing variations with Mockito. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions. Step 06 : Introduction to BDD. Given When Then. BDD Mockito Syntax. Step 07 : How to verify calls on a mock? Verify how many times a method is called. We will add deleteTodo method to the TodoService. Step 08 : How to capture an argument which is passed to a mock? Step 09 : Hamcrest Matchers. Step 10 : Let's simplify things with Mockito Annotations. @Mock, @InjectMocks, @RunWith(MockitoJUnitRunner.class), @Captor Step 11 : JUnit Rules. Using MockitoJUnit.rule() instead of @RunWith(MockitoJUnitRunner.class). Step 12 : Real world Example with Spring Step 13 : What is a spy? How to spy with Mockito? Step 14 : Some Theory : Why does Mockito not allow stubbing final and private methods? Step 15 : Using PowerMock and Mockito to mock a Static Method. Step 16 : Using PowerMock and Mockito to invoke a private Method. Step 17 : Using PowerMock and Mockito to mock a constructor. Step 18 : Good Unit Tests. JUnit Step 01 : Need for Unit Testing Step 02 : Setting up your First JUnit Step 03 : First Successful JUnit. Green Bar and assertEquals Step 04 : Refactoring Your First JUnit Test Step 05 : Second JUnit Example assertTrue and assertFalse Step 06 : @Before @After Step 07 : @BeforeClass @AfterClass Step 08 : Comparing Arrays in JUnit Tests Step 09 : Testing Exceptions in JUnit Tests Step 10 : Testing Performance in JUnit Tests Step 11 : Parameterized Tests Step 12 : Organize JUnits into Suites

Views

Total views

887

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

14

Shares

0

Comments

0

Likes

0

×