This chapter will explain about how to integrate JUnit and Mockito together. For this we need to create a Math Application which uses CalculatorService to perform basic mathematical operations such as addition, subtraction, multiply, and division.
We'll use Mockito to mock the dummy implementation of CalculatorService. Along with this, using annotations will helps to showcase their compatibility with both JUnit and Mockito.
Junit integration process is explained here in a step-by-step manner.
Now,test the MathApplication class, by injecting in it a mock of calculatorService.
Create a java class file named TestRunner in C> Mockito_WORKSPACE to execute Test case(s).
Compile the classes using javac compiler as follows –
Now run the Test Runner to see the result –
Verify the output.
Mockito Related Interview Questions
|Python Interview Questions||HTML 5 Interview Questions|
|MySQL Interview Questions||JDBC Interview Questions|
|Ruby on Rails Interview Questions||SQL Interview Questions|
|Hibernate Interview Questions||UI Developer Interview Questions|
|Test-driven development (TDD) Interview Questions||Java Interview Questions|
|Advanced Linux Interview Questions||Agile Methodology Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.