Mocking

Testing in Scala (Frameworks, Code Coverage, Mocking, Matchers, and ScalaTest)

Reading Time: 5 minutes We will be covering the below concepts in this blog: Why we need testing Test Libraries How to set up ScalaTest Different frameworks in ScalaTest and how to use them Mocking  Matchers Plugins for Code Coverage Why we need testing: Firstly, as a good software developers it is important to use testing that is good and has good coverage. Testing is an essential part of Continue Reading

Unit testing with Mockito Framework

Reading Time: 3 minutes In this blog, we are going to learn about how we can use mockito framework to perform unit testing. Mockito framework provides us several methods which we can use to perform unit test. What is Unit Testing Unit testing is a software testing technique in which we only test a single component of the software. We ignore the output of the dependent module and test Continue Reading

Unit testing void methods with Mockito and JUnit

Reading Time: 3 minutes Writing functionality is the main focus whenever we are writing a software program, but it is equally important that we make sure our code works the way we intended it to. And how do we do that? By writing unit test cases. They are used to test the smallest functionality of code. Unit test cases are an essential part of software development. In this blog, Continue Reading

Monkey patching in NodeJS

Reading Time: 3 minutes Hey guys, I am back with another blog in my series of blogs on mocking in nodeJS, so if you have read my last blog, in which we looked over how we can use sinon for testing in nodeJS to effectively mock and stub behaviours, so in this blog we would look over the concept of monkey patching to make things more testable, so let’s Continue Reading

Beginners Guide for Mocking in Scala

Reading Time: 3 minutes We all must know how the unit test cases are one of the most important part of an application. If not? Then I must tell you that unit testing is one of the earliest testings which is performed on the unit of code and the earlier the defects are detected, the easier it is to fix. It reduces the difficulties of discovering errors contained in Continue Reading

Mocking static methods with PowerMock

Reading Time: 2 minutes A good developer always writes a unit test case for his/her code. While writing test cases, we came across various types of scenarios, including the one where we need to mock static methods. One of the common examples of such scenario is where our service is using some static methods from a third party library. Here, one way to deal is to have an adapter Continue Reading

Knolx : Exploring the power of JMockit

Reading Time: < 1 minute Hello everyone, Knoldus organized a session on 22nd December 2017. The topic was “JMockit”. Many people attended and enjoyed the session. In this blog post, I am going to share the slides & video of the session. Slides: JMockit from Knoldus Inc. Video: If you have any query, then please feel free to comment below.

Difference between Mockito and JMockit

Reading Time: 2 minutes A Brief analysis on Mockito And Jmockit Mockito JMockit 1. We can achieve Static method/constructor mocking by the combination of Mockito with Powermock. 1. Static method/constructor can be mocked directly in JMockit. 2. The Mockito API contains several inconsistencies in the syntax used for invocations to mocked methods. In the record phase, we have calls like when(mock.mockedMethod(args))… while in the verify phase this same call Continue Reading

JMockit: A beginner’s guide for Unit Testing

Reading Time: 5 minutes So we are following TDD, And we are working on unit test cases, And then we are stuck with mocking. Well this was the situation we faced. And while going through various API tools for mocking, we came through this amazing toolkit: JMockit. What is JMockit? JMockit is open source software licensed under the MIT License. It includes APIs for mocking, faking, and integration testing, Continue Reading

Mocking Mail API in Scala

Reading Time: 2 minutes Few days ago I was working on a Mailing API of my project and used javax-mail API but encountered the problem of how to write unit test cases for that without actually mocking the mail. I searched for it but was unable to find a proper documentation about mocking a mailing service. I tried few methods but some were confusing and some were really complex. Then I Continue Reading